Should lxc start network with = up and without any net init script inside CT?

Something went wrong again :frowning:

lxc-create -n test-1 -t download -B loop --fssize 5G --fstype ext4 -- -d centos -r 7 -a amd64

cat <<EOF >/var/lib/lxc/test-1/config
# Template used to create this container: /usr/share/lxc/templates/lxc-download
# Parameters passed to the template: -d centos -r 7 -a amd64
# Template script checksum (SHA-1): 273c51343604eb85f7e294c8da0a5eb769d648f3
# For additional config options, please look at lxc.container.conf(5)

# Uncomment the following line to support nesting containers:
#lxc.include = /usr/share/lxc/config/nesting.conf
# (Be aware this has security implications)

# Distribution configuration
lxc.include = /usr/share/lxc/config/common.conf
lxc.arch = x86_64

# Container specific configuration
lxc.rootfs.path = loop:/var/lib/lxc/test-1/rootdev = test-1

# Network configuration = up = = = br0 = eth0 = veth

lxc-start test-1
lxc-attach test-1

now what we see: ip a says us eth0 is in UP state with correct address but ip r says - there is no default gateway. Ok, here is default net script /etc/sysconfig/network-scripts/ifcfg-eth0 trying to get dhcp, lets remove it. rm -rf /etc/sysconfig/network-scripts/ifcfg-eth0 ; shutdown -h now . Start CT again lxc-start test-1 , and now eth0 with correct address but in DOWN state and there is still no default gateway. BTW with (eth1) all works fine. What i broke on this time? :’(

First, for future proofing, please ensure the = veth is first before any other* lines.

You mention that is working ok, does that mean you’ve specified a gateway on both nics, as you cannot have 2 default gateways.

hey @tomp ! Glad to see you again!
Tried to set = veth before others* - it has no effect.
No, i removed default gateway from and then set it to and (eth1) works as expected (state UP and with default getaway)

Current versions of LXC will require you to set type first before other config, so just a heads up to start doing that to avoid problems in the future.

If it works when passing the NIC in as eth1 then it means some network config inside the container is wiping the default route. This will be distro dependent. It may be trying to do a DHCP request, so ensuring that DHCP client is disabled in network config would be a good start.

Yes, i tried to move = veth to config’s head - but it has no effect.
And yes there is a config /etc/sysconfig/network-scripts/ifcfg-eth0 who ttried to get ippadr with DHCP, but as i said - i tried to del it, and it didn’t help too.
I have no idea what might be wrong with default centos template :frowning:

I wouldn’t expect it to have any effect, not yet anyway. But in the future itll save it from breaking.

My suggestion would be to run tcpdump on the host-side of the veth pair and check no DHCP requests are coming from the container, if they are, then its still enabled somehow.

But how i can do that, if after remove /etc/sysconfig/network-scripts/ifcfg-eth0 eth0 is in DOWN state? As i asked in title: shouldn’t = up UP interface on container start?

Looks like the commit by @monstermunchkin is the problem here:

You can fix it by doing systemctl disable network-device-down.service.
And then I set the network config to:


Have opened issue to see if we can fix it without breaking something else:

wow, @tomp u are too fast 4 me :slight_smile:
Yeah, i remembered that i have an old build (20200427_07:08) , so i find commit before this date, built it with distrobuilder build-lxc centos.yaml -o image.architecture=x86_64 -o image.release=7 and there is no such problem!

1 Like