LXC container gets 2 IP addresses

SBSTP asked:

I want to have a flat configuration where the host and guest all have their own static addresses on the network. For some unknown reason however, the container is assigned 2 addresses, and I’m only interested in having one,

The host’s network configuration:

# Host /etc/network/interfaces
auto lxcbr0
iface lxcbr0 inet static
    bridge_ports p4p1
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

The guest’s configuration inside the host:

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.hwaddr = 00:16:3e:08:b6:78
lxc.network.ipv4 =

The guest’s network configuration:

auto eth0
iface eth0 inet dhcp

When I start the container and use lxc-ls -f I get:

NAME  STATE    IPV4                          IPV6                                    AUTOSTART  
name  RUNNING,  2607:fa48:6de9:f3a0:216:3eff:fe08:b678  YES    

My answer:

The reason is that you explicitly asked for two IP addresses.

First, you asked the host to configure a static IP address for the container, which is active as the container starts. Then you asked the container to request a second IP address with DHCP.

You should remove those two lines from /etc/network/interfaces if you don’t want the second IP address.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.