Deep Tech Point
first stop in your tech adventure

How to add failover/ alias IP address in Linux

July 1, 2022 | Linux

The procedure for adding IP addresses  is very similar on all Linux distributions.  It requires editing network interfaces file and restarting network service. Keep in mind that these specific instructions are tested on Ubuntu.

So you received your failover IP in standard format This method is permanent static setup which will be loaded during OS boot

Open /etc/network/interfaces file:

#cnano /etc/network/interfaces

Assuming that eth0 is your network interface you want to add failover IP address add following at the end of the file:

auto eth0:0
iface eth0:0 inet static

So as you can see every IP alias has index number starting with zero for first IP and continuing with every additional IP alias. So the pattern is:

auto ethX:Y
iface ethX:Y inet static

Finally you should restart network service using:

# systemctl restart networking

And don’t forget sudo if you’re working with non-root user. Useful command for checking network interfaces is:

# ifconfing -a

If you need to add IP only temporary (until next reboot) you can do this:

# ip addr add dev eth0