Configure a Failover IP
This guide explains how to configure a Failover IP on your Linux VPS. Choose the section matching your distribution and its network manager.
Prerequisites
- SSH root or sudo access
- A Failover IP assigned to your VPS
- Linux system (Debian, Ubuntu, AlmaLinux, Rocky Linux, Fedora…)
Configuration with ifupdown (/etc/network/interfaces)
Legacy method used on Debian and older Ubuntu versions. If your system uses Netplan (Ubuntu 18.04+), refer to the next section.
-
Disable automatic network configuration:
sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfgAdd this line:
network: {config: disabled} -
Configure the virtual interface:
sudo nano /etc/network/interfaces.d/50-cloud-initAdd these lines:
# Failover IP interfaceauto eth0:1iface eth0:1 inet staticaddress YOUR_FAILOVER_IPnetmask 255.255.255.255 -
Restart the network service:
sudo systemctl restart networking
Configuration with Netplan (Ubuntu 18.04+)
On recent Ubuntu-based systems, the network is managed by Netplan rather than by /etc/network/interfaces. Use this method instead of the previous section.
-
Identify your network interface name:
ip a(for example
eth0,ens3orenp1s0) -
Edit the Netplan configuration file:
sudo nano /etc/netplan/50-cloud-init.yamlAdd the Failover IP to your interface, keeping the existing configuration (mind the YAML indentation, 2 spaces):
network:version: 2ethernets:eth0:addresses:- YOUR_FAILOVER_IP/32 -
Apply the configuration:
sudo netplan apply
Tip: use
sudo netplan tryinstead ofnetplan applyto test; the configuration is automatically rolled back after 120 seconds if you don't confirm it, which prevents losing SSH access in case of an error.
Configuration with network-scripts (AlmaLinux / Rocky Linux 8 and 9)
On RHEL-based distributions (AlmaLinux, Rocky Linux 8 and 9), create a dedicated configuration file for the virtual interface.
-
Identify your network interface name:
ip a(for example
eth0orens3) -
Create the alias configuration file:
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0:1Add these lines:
DEVICE=eth0:1BOOTPROTO=staticIPADDR=YOUR_FAILOVER_IPNETMASK=255.255.255.255ONBOOT=yes -
Restart the network service:
sudo systemctl restart NetworkManager
Configuration with NetworkManager (Fedora, AlmaLinux, Rocky Linux)
On Fedora and recent versions of AlmaLinux and Rocky Linux, the network is managed directly through NetworkManager connection files.
-
Identify your interface connection file:
ls /etc/NetworkManager/system-connections/ -
Edit the matching connection file (for example
cloud-init-eth0.nmconnection):sudo nano /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnectionIn the
[ipv4]section, add the Failover IP:[ipv4]method=autoaddress1=YOUR_FAILOVER_IP/32 -
Restart NetworkManager:
sudo systemctl restart NetworkManager
Verification
-
Verify that the IP is properly configured:
ip addr show -
Test connectivity:
ping -I YOUR_FAILOVER_IP 8.8.8.8
Best practices
- Document your network configurations
- Test the configuration before any production deployment
- Keep a backup of configuration files
- Configure alerts in case of connectivity loss
Troubleshooting
- Check system logs:
sudo journalctl -xe - Check network configuration:
sudo networkctl status - Make sure the IP is properly assigned to your VPS
- Verify there is no IP conflict
- As a last resort, boot your server in rescue mode and add the IP on the fly:
ip addr add YOUR_FAILOVER_IP/32 dev eth0
Important notes
- The Failover IP must be configured with a network mask 255.255.255.255
- Some services may require reconfiguration to use the new IP
- Configuration may vary depending on your Linux distribution