Updated : Jun 30, 2015 in Linux

Adding IPs to a network Interface in Linux

Sometimes we need to add extra IPs to a network interface to handle HTTPS requested by mechanisms that don’t support SNI. There are many ways to do that but here are the one I prefer.

Extra IP belonging to a different subnet

In order to be able to add an extra IP belonging to another subnet then the one already existing, the suggestion is:
Adding an extra IP and assign it to a ‘virtual’ interface eth0:xtra which is in fact a second name for the interface eth0.
Add the following in /etc/network/interfaces
auto eth0:xtra
iface eth0:xtra inet static

Extra IP belonging to the same subnet

In case of adding an extra IP that belongs to the same subnet as the one already existing the suggestion is:
Note: Here I display the full interface configuration but the part to add is only at the end which starts with ‘up’ or ‘down’
In file /etc/network/interfaces
auto eth0
iface eth0 inet static
up /sbin/ip addr add dev eth0
down /sbin/ip addr del dev eth0

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: