LXC - struggling with assigning a failover IP address to a Linux Container


#1

I am struggling with assigning a failover IP address to my Linux Container (LXC). I think the problem lies in the configuration of the container, as apparently setting ipv4 and gateway in the LXC configuration file is not enough. Pinging anything from inside the container returns 100% packet loss.

Here is what I did:

apt-get install -y lxc bridge-utils

change /etc/network/interfaces - replace "eth0" with "br0" and add "bridge_ports eth0"

auto br0
iface br0 inet static
bridge_ports eth0
address 91.229.20.xx <-- main IP of server
netmask 255.255.255.0
network 91.229.20.0
broadcast 91.229.20.255
gateway 91.229.20.1
dns-nameservers 4.2.2.1

reboot

lxc-create -t download -n vps1 -- --dist ubuntu --release xenial --arch amd64

adjust /var/lib/lxc/vps1/config

lxc.network.type = veth
lxc.network.link = br0 <-- changed from lxcbr0 default bridge
lxc.network.flags = up
lxc.network.hwaddr = 52:54:00:00:XX:XX <-- supplied by provider
lxc.network.ipv4 = 91.236.255.xx/24 <-- this is the failover IP
lxc.network.ipv4.gateway = 91.229.20.1

lxc-start -n vps1

lxc-attach -n vps1

No network connection inside the container. Ping is impossible.

I tried to adjust /etc/network/interfaces in the container from DHCP to

auto eth0

iface eth0 inet static
address 91.236.255.xx <-- failover IP
netmask 255.255.255.0
network 91.229.20.0
broadcast 91.229.20.255

(I also tried to add gateway 91.229.20.1, or only the address without netmask/network/broadcast)
The failover IP works on the host when I configure it like this:

auto eth0:1
iface eth0:1 inet static
address 91.236.255.xx <-- failover IP
netmask 255.255.255.0
network 91.229.20.0
broadcast 91.229.20.255

What am I doing wrong? I would greatly appreciate some help, as I am out of ideas.