Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


LXC - struggling with assigning a failover IP address to a Linux Container
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

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

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.

Comments

  • Network settings in container looks weird to me. The gateway IP is out of your container network, probably you need to add routing to your gw IP thru the interface and then add default gw.

    You can find similar configuration here: https://forum.proxmox.com/threads/lxc-and-ovh-failover-ip.23907/

    Thanked by 1torrbox
  • @jamzed said:
    Network settings in container looks weird to me. The gateway IP is out of your container network, probably you need to add routing to your gw IP thru the interface and then add default gw.

    You can find similar configuration here: https://forum.proxmox.com/threads/lxc-and-ovh-failover-ip.23907/

    Hmm the way I remember is that just providing the static IP in the container's eth0 was sufficient. But it doesn't work now.

    I tried the example, but it didn't work:

    auto eth0 iface eth0 inet static address 91.236.255.xx <-- failover IP netmask 255.255.255.0 broadcast 91.229.255.xx <-- failover IP post-up route add 91.229.20.1 dev eth0 <-- gateway of host IP post-up route add default gw 91.229.20.1 pre-down route del 91.229.20.1 dev eth0 pre-down route del default gw 91.229.20.1

    rebooted container afterwards

  • Failover IP netmask probably should be 255.255.255.255, broadcast you can remove, isn’t correct. One more thing to check with your provider is Virtual Mac, maybe it’s required for your setup.

    Thanked by 1torrbox
  • @jamzed said:
    Failover IP netmask probably should be 255.255.255.255, broadcast you can remove, isn’t correct. One more thing to check with your provider is Virtual Mac, maybe it’s required for your setup.

    I am using a virtual MAC that I created in my provider's control panel.

    Just by adding the following to the LXC config I already get the correct address, broadcast, and netmask in the container (I checked with ifconfig). I tried netmask *.255 and *.0

    lxc.network.ipv4 = 91.236.255.xx/24 <-- this is the failover IP lxc.network.ipv4.gateway = 91.229.20.1 <-- gateway of host IP

    Not sure what to do now.. everything should be correct, at least to my knowledge, it just doesn't work.

  • torrboxtorrbox Member
    edited November 2017

    @jamzed said:
    Failover IP netmask probably should be 255.255.255.255, broadcast you can remove, isn’t correct. One more thing to check with your provider is Virtual Mac, maybe it’s required for your setup.

    UPDATE: I went to BuyVM and the instructions I posted work flawlessly there. ¯\_(ツ)_/¯ Looks like my provider is at fault.

    Thanks for your help.

Sign In or Register to comment.