On Ubuntu
Default config look like
root@zecurecode:~# cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # Source interfaces # Please check /etc/network/interfaces.d before changing this file # as interfaces may have been defined in /etc/network/interfaces.d # See LP: #1262951 source /etc/network/interfaces.d/*.cfg root@zecurecode:~#
/etc/network/interfaces.d/50-cloud-init.cfg is used to auto configure network interface with dhcp.
root@zecurecode:~# cat /etc/network/interfaces.d/50-cloud-init.cfg # This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} auto lo iface lo inet loopback auto ens3 iface ens3 inet dhcp root@zecurecode:~#
First find the gateway used by the VPS.
root@zecurecode:~# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 51.254.32.1 0.0.0.0 UG 0 0 0 ens3 51.254.32.1 0.0.0.0 255.255.255.255 UH 0 0 0 ens3 root@zecurecode:~#
We found the gateway IP 51.254.32.1
The VPS had main IP of the server is 51.254.35.58 and secondary IPS 94.23.153.137, 178.32.52.159, 178.32.49.157
Here is the modified /etc/network/interfaces
root@zecurecode:~# cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # Source interfaces # Please check /etc/network/interfaces.d before changing this file # as interfaces may have been defined in /etc/network/interfaces.d # See LP: #1262951 #source /etc/network/interfaces.d/*.cfg auto ens3 iface ens3 inet static address 51.254.35.58 netmask 255.255.255.255 broadcast 51.254.35.58 post-up route add 51.254.32.1 dev ens3 post-up route add default gw 51.254.32.1 post-down route del default gw 51.254.32.1 post-down route del 51.254.32.1 dev ens3 auto ens3:1 iface ens3:1 inet static address 94.23.153.137 netmask 255.255.255.255 broadcast 94.23.153.137 auto ens3:2 iface ens3:2 inet static address 178.32.52.159 netmask 255.255.255.255 broadcast 178.32.52.159 auto ens3:3 iface ens3:3 inet static address 178.32.49.157 netmask 255.255.255.255 broadcast 178.32.49.157 root@zecurecode:~#
Here is a PHP script to create OVH failover IP config for Ubuntu/Debian.
https://gist.github.com/serverok/991f7ccd1be36cbc579e8d55caf39715