LXC container gets two IP addresses assigned to it
5 marzo, 2021 por
LXC container gets two IP addresses assigned to it
| Sin comentarios aún

So after a little bit more research I’ve determined why this is happening. I’m using the default Ubuntu and Debian templates to create the containers and their networking is set up so as to use DHCP to ask for a IP from the the router. So initially the static IP is set using the lxc.container.config and then when the container starts it queries the router (or whatever DHCP server you have) for a secondary IP that’s then assigned to it.

The most logical way to stop this is likely to just assign the static ip inside the container. So on Debian based templates edit /etc/network/interfaces:

auto etho0
iface etho0 inet static

And then remove the ipv4 line from the lxc config /var/lib/lxc/testcontainer/config:

lxc.network.type = veth
lxc.network.link = br0

Another method is to let the host set the ip by keeping the ipv4 line in /var/lib/lxc/testcontainer/config and to tell the container explicitly to not touch the interface by setting it to manual:

auto eth0
iface eth0 inet manual

Apparently there are some issues with this second method if the host is suspended and then resumed. Probably best to use the first method.

Identificarse dejar un comentario