Container static IP disappears in ~1min after startup

Hi All,

In my setup, I have configured the container’s config to get a static IP. The IP shows up on the veth interface, lxc-ls -f, but it will mysteriously disappear around a minute after starting the container. I’m using lxc-net to setup lxcbr0 and veth pairs. I’m running lxc 3.1.0.

Container’s config:
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.hwaddr = 00:16:3e:1a:14:12
lxc.net.0.ipv4.address = 10.0.3.32/24
lxc.net.0.ipv4.gateway = 10.0.3.1
lxc.net.0.mtu = 1500
lxc.net.0.flags = up

/etc/default/lxc-net
USE_LXC_BRIDGE=“true”
LXC_ADDR=“10.0.3.1”
LXC_NETMASK=“255.255.255.0”
LXC_NETWORK=“10.0.3.0/24”
LXC_DHCP_RANGE=“10.0.3.100,10.0.3.254”
LXC_DHCP_MAX=“155”

I’m not sure if the config is wrong or something else is causing this issue. Any help is much appreciated.

Thanks!

@brian is your container running a DHCP client that is periodically getting a dynamic IP from the DHCP server rather than keeping your manually assigned static IP?

@tomp The container isn’t running a DHCP client. I’ve also tried disabling dnsmasq and unplugging the Ethernet from the host machine, and the issue still persists. However, when I manually add the IP to the interface as root user(su) in the container, then the static IP will persist. If the container is started in privileged mode, then perhaps the static IP won’t disappear?

@brian does it happen if you do not connect your LXC container to the bridge, i.e remove the link line?

@tomp I removed the link line from the container’s and default config, but the IP still disappears.

OK @brian so that rules out DHCP I think.

Can you try the same config but with a freshly downloaded image, and can you let me know what distro you’re running?

@brian By chance, are you running cloud-init on this container?

@tomp I’ll give a new image a go and I’m running an Android container.

@rkelleyrtp Nope, no cloud-init.