msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

30 Jun 15 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
address 192.168.10.45
netmask 255.255.255.0
network 192.168.10.0
broadcast 192.168.10.255

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
address 10.45.13.154
netmask 255.255.255.0
network 10.45.13.0
broadcast 10.45.13.255
gateway 10.45.13.254
up /sbin/ip addr add 10.45.13.155/24 dev eth0
down /sbin/ip addr del 10.45.13.155/24 dev eth0

Leave a Reply

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

%d bloggers like this: