[lxc-users] Race condition in IPv6 network configuration

MegaBrutal megabrutal at gmail.com
Mon Nov 6 13:15:00 UTC 2017


Hi all,

I experience an annoying race condition when my LXC container's
network interface comes up. By default, nodes are expected to
configure themselves with Router Advertisements; but for some
containers, I'd prefer to set a static address. In these containers, I
use a static configuration in /etc/network/interfaces, and explicitly
disable RAs. Yet somehow, these containers configure themselves
through RA before the static configuration would occur. Then the
static address is added, but the default route acquired from RA stays
there. Then as RAs get disabled, this default route expires after
time, and the host remains without a default route. Then I receive
ping test fail alerts on my monitoring system... If I reboot the
container multiple times, once I'll get lucky and the interface
configuration happens before an RA is received, and I get a permanent
default route and everything's fine. But it's annoying because I have
to reboot the container multiple times before it happens.

What am I doing wrong?

Here is my LXC config file:

# Template used to create this container: /usr/share/lxc/templates/lxc-ubuntu
# Parameters passed to the template: -S /home/megabrutal/.ssh/id_rsa.pub
# For additional config options, please look at lxc.conf(5)

# Common configuration
lxc.include = /usr/share/lxc/config/ubuntu.common.conf

# Container specific configuration
lxc.start.auto = 1
lxc.rootfs.path = /dev/vmdata-vg/lxc-reverse
lxc.rootfs.options = subvol=@reverse
lxc.uts.name = reverse
lxc.arch = amd64

# Network configuration
lxc.net.0.type = veth
lxc.net.0.hwaddr = 00:16:3e:7b:9e:b4
#lxc.net.0.flags = up
lxc.net.0.link = br0


Take a note how I explicitly commented out the net flags, as I don't
want the interface to be in UP state when the container starts; I want
the container to configure its interface for itself. At first, I
thought commenting out "lxc.net.0.flags = up" would solve the issue,
and sure it did help something, because at least now the configuration
SOMETIMES works as intended. Before that, the static configuration
never succeeded.

Here is /etc/network/interfaces from within the container:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

iface eth0 inet6 static
        address 2001:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
        netmask 64
        gateway fe80::xxxx:xxxx:xxxx:xxxx
        autoconf 0
        accept_ra 0


So I want the container to receive its IPv4 address through DHCP and
have a static IPv6 configuration at the same time. What is the best
practice for this without race conditions with RA?

Note: I use the old LXC interface / tools, have no plans to migrate to LXD yet.
Thanks for your help in advance!


Regards,
MegaBrutal


More information about the lxc-users mailing list