I am trying out LXD. It seems the default way to set up networking is to have the host provide DHCP and NAT for all the guests, but I'd like to omit NAT and allow the guests to use the same DHCP server as the host. This seems like it should be a pretty reasonable thing to want, but I can't get it working. No matter what I do, the guest never gets an address assigned by the external DHCP server.
To make things harder, it looks like LXD's network configuration changed pretty majorly with LXD 2.3, and the vast majority of information I find out there is for earlier versions. I did find this one GitHub issue where someone was trying to do the same thing and posted a new-style configuration that worked for them, but it didn't seem to make a difference when I tried it.
So, the question is, How do I set up a bridge in LXD 2.3+ without NAT and using external DHCP?
Here is some additional detail:
- Ubuntu 18.04 with LXD 3.0.0
- Host uses interface enp10s0f0
- Want to bridge guests to interface enp10s0f1 (which is not otherwise used by the host)
- Additional interface enp1s2 unused
dominickpastore@ubuntu:~$ lxc network list +-----------+----------+---------+-------------+---------+ | NAME | TYPE | MANAGED | DESCRIPTION | USED BY | +-----------+----------+---------+-------------+---------+ | enp10s0f0 | physical | NO | | 0 | +-----------+----------+---------+-------------+---------+ | enp10s0f1 | physical | NO | | 0 | +-----------+----------+---------+-------------+---------+ | enp1s2 | physical | NO | | 0 | +-----------+----------+---------+-------------+---------+ | lxdbr0 | bridge | YES | | 1 | +-----------+----------+---------+-------------+---------+
Note that this is just my current configuration attempt for
lxdbr0
; I've tried many:dominickpastore@ubuntu:~$ lxc network show lxdbr0 config: bridge.external_interfaces: enp10s0f1 ipv4.address: none ipv4.dhcp: "false" ipv6.address: none ipv6.dhcp: "false" description: "" name: lxdbr0 type: bridge used_by: - /1.0/containers/first managed: true status: Created locations: - none
Update:
I have been playing with this more and it's leaving me even more confused. I'm getting seemingly very erratic behavior. Is this still kind of new and flaky, or am I just doing stuff wrong? For one thing, lxc network unset
doesn't seem to work:
dominickpastore@ubuntu:~$ lxc network show lxdbr0
config:
ipv4.address: 10.4.4.1/24
ipv4.dhcp: "true"
ipv4.dhcp.ranges: 192.168.4.230-192.168.4.249
ipv4.nat: "true"
ipv4.routing: "true"
ipv6.address: none
ipv6.dhcp: "false"
description: ""
name: lxdbr0
type: bridge
used_by:
- /1.0/containers/first
managed: true
status: Created
locations:
- none
dominickpastore@ubuntu:~$ lxc network unset lxdbr0 ipv4.dhcp.ranges
dominickpastore@ubuntu:~$ lxc network show lxdbr0
config:
ipv4.address: 10.4.4.1/24
ipv4.dhcp: "true"
ipv4.dhcp.ranges: 192.168.4.230-192.168.4.249
ipv4.nat: "true"
ipv4.routing: "true"
ipv6.address: none
ipv6.dhcp: "false"
description: ""
name: lxdbr0
type: bridge
used_by:
- /1.0/containers/first
managed: true
status: Created
locations:
- none
I've also created a second bridge to test two configurations at once, and I can set them very similarly to a NAT+DHCP configuration (not exactly the same because unset isn't working) yet only the original interface gets assigned an address. I can't figure out why the new interface can't get an address at all. Notice the similar IPv4 configuration:
dominickpastore@ubuntu:~$ lxc network show lxdbr0
config:
ipv4.address: 10.4.4.1/24
ipv4.dhcp: "true"
ipv4.dhcp.ranges: 192.168.4.230-192.168.4.249
ipv4.nat: "true"
ipv4.routing: "true"
ipv6.address: none
ipv6.dhcp: "false"
description: ""
name: lxdbr0
type: bridge
used_by:
- /1.0/containers/first
managed: true
status: Created
locations:
- none
dominickpastore@ubuntu:~$ lxc network show lxdbr1
config:
ipv4.address: 10.251.34.1/24
ipv4.dhcp: "true"
ipv4.nat: "true"
ipv4.routing: "true"
ipv6.address: none
ipv6.nat: "false"
description: ""
name: lxdbr1
type: bridge
used_by:
- /1.0/containers/first
managed: true
status: Created
locations:
- none
Yet, in the container, eth0 works (connected to lxdbr0) and eth1 never gets an address (connected to lxdbr1):
root@first:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
41: eth0@if42: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:64:0e:ea brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.4.4.245/24 brd 10.4.4.255 scope global dynamic eth0
valid_lft 3101sec preferred_lft 3101sec
inet6 fe80::216:3eff:fe64:eea/64 scope link
valid_lft forever preferred_lft forever
43: eth1@if44: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:fe:6d:01 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::216:3eff:fefe:6d01/64 scope link
valid_lft forever preferred_lft forever