1

I have a Ubuntu 16.04 server and default LXD configuration.

Typically, when an image comes up, this happens:

eno1      Link encap:Ethernet  HWaddr b8:ae:ed:ea:69:41  
          inet addr:192.168.0.3  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::baae:edff:feea:6941/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:116948 errors:0 dropped:3 overruns:0 frame:0
          TX packets:59726 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:161031770 (161.0 MB)  TX bytes:4656462 (4.6 MB)
          Interrupt:16 Memory:df100000-df120000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:177 errors:0 dropped:0 overruns:0 frame:0
          TX packets:177 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:13388 (13.3 KB)  TX bytes:13388 (13.3 KB)

lxdbr0    Link encap:Ethernet  HWaddr fe:5c:57:cd:bd:72  
          inet addr:10.41.63.1  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fd6d:c772:b128:ebfd::1/64 Scope:Global
          inet6 addr: fe80::d08c:f9ff:fed9:5cd1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:39 errors:0 dropped:0 overruns:0 frame:0
          TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5064 (5.0 KB)  TX bytes:11128 (11.1 KB)

vethD7L5U9 Link encap:Ethernet  HWaddr fe:5c:57:cd:bd:72  
          inet6 addr: fe80::fc5c:57ff:fecd:bd72/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:39 errors:0 dropped:0 overruns:0 frame:0
          TX packets:75 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5610 (5.6 KB)  TX bytes:10322 (10.3 KB)

And the image looks like this:

+-------+---------+---------------------+-----------------------------------------------+------------+-----------+
| NAME  |  STATE  |        IPV4         |                     IPV6                      |    TYPE    | SNAPSHOTS |
+-------+---------+---------------------+-----------------------------------------------+------------+-----------+
| first | RUNNING | 10.41.63.206 (eth0) | fd6d:c772:b128:ebfd:216:3eff:fe9d:ef41 (eth0) | PERSISTENT | 0         |
+-------+---------+---------------------+-----------------------------------------------+------------+-----------+

I would like to take the option of using my own bridge as this is an option in reconfiguration. It seems it's not as simple as I thought.

I create a simple bridge.

iface vbr0 inet static
        address 10.10.10.1
        broadcast 255.255.255.0
        pre-up          brctl addbr vbr0
        post-down       brctl delbr vbr0

I restart my container and don't get an IP.

+-------+---------+------+------+------------+-----------+
| NAME  |  STATE  | IPV4 | IPV6 |    TYPE    | SNAPSHOTS |
+-------+---------+------+------+------------+-----------+
| first | RUNNING |      |      | PERSISTENT | 0         |
+-------+---------+------+------+------------+-----------+

But do get veth come up.

vbr0      Link encap:Ethernet  HWaddr fe:da:17:ca:ab:e0  
          inet addr:10.10.10.1  Bcast:255.255.255.0  Mask:255.0.0.0
          inet6 addr: fe80::e83b:1aff:fe18:4652/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:36 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7632 (7.6 KB)  TX bytes:908 (908.0 B)

vethWLPBCC Link encap:Ethernet  HWaddr fe:da:17:ca:ab:e0  
          inet6 addr: fe80::fcda:17ff:feca:abe0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4410 (4.4 KB)  TX bytes:948 (948.0 B)

The is no dnsmasq running (which one would expect) so I'm not sure where that comes into play. If I run it by hand, my containers get IP addresses (after restart).

Can someone give pointers as how to replicate the lxdbr0 bridge and consequential dnsmasq instantiation?

1 Answer 1

0

Bridge + dnsmasq guest networking

Looks like you're missing two steps that LXC / LXD normally handles for you. With LXC, this is handled by the lxc-net service.

Fundamentally, what happens is this:

  1. The bridge is created
  2. A dnsmasq instance is started, listening on the bridge interface
  3. iptables rules are added to provide NAT, DHCP, and basic ICMP traffic.

You can see this exact behavior if you look at the source for the lxc-net init scripts. (and probably the lxd equivalent)

Deploying it

You could either:

  1. Copy and modify the lxc-net script from lxc / your distribution (look in /etc/init/lxc-net or by going here: lxc-net (official master).
    • Place it in your init scripts (/etc/init/) and name it something unique. You can then start / stop it as if it was it's own service.
  2. Write your own script, based off of the existing ones.

You'll want to add this script in place of your pre-up / post-down commands. Be sure it's marked as executable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .