Add failover IP Ubuntu 20.04
Answers to your questions / Bare Metal / Add failover IP Ubuntu 20.04
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

Add failover IP Ubuntu 20.04

by
MarcR1
Created on 2021-04-11 14:00:14 (edited on 2024-09-04 14:23:19) in Bare Metal

Hello,

I bought a Failover IP and I don't know how to install it, is an updated tutorial?


2 Replies ( Latest reply on 2021-05-01 11:00:14 by
RobD
)

Create a file /etc/netplan/51-failover.yaml with the following content:
> network:
> version: 2
> renderer: networkd
> ethernets:
> eno0:
> addresses:
> - 1.2.3.4/32
Replace eno0 with the applicable external network interface (use "ip a" or look at the welcome screen), replace 1.2.3.4 with your failover IP, and add multiple lines if you have multiple ip addresses. Now issue "sudo netplan try". If you somehow did mess up your server will recover in 120 seconds. If you accept the configuration, the failover IP should now be listed at "ip a".

Multiple older tutorials didn't actually seem to work, but this has worked successfully for us to setup a OVH failover IP on Ubuntu 20.04.

Note that the above works for almost the whole internet, except for other servers in the same /24 that do not already have an entry in "arp" that is not "(incomplete)". To fix this, something extra is needed because arp packets with the failover ip as source adress are filtered, and you cannot broadcast the failover ip with arp. Let's say your server ip (not the failover ip) is 5.6.7.8, you need:
`sudo arptables -A OUTPUT -d 5.6.7.0/24 -j mangle --mangle-ip-s 5.6.7.8`

To persist this on reboot, you need some extra things. You can save the config, e.g.:
`sudo arptables-save | sudo tee /etc/iptables/rules.arp`
To reload it using the netfilter-persistent package if present (installed by iptables-persistent), create an executable file plugin for arp, e.g.:
`echo "arptables-restore < /etc/iptables/rules.arp" | sudo tee /usr/share/netfilter-persistent/plugins.d/35-arptables`
`sudo chmod +x /usr/share/netfilter-persistent/plugins.d/35-arptables`