Adding Additional IP Address to a Network Interface

Linux network interfaces allow more than one IP address to be assigned.

With just the one network connection multiple IP addresses can be used. Thus allowing a unique IP address per website, for example.

Additional network IP addresses are configured in the file

/etc/network/interfaces

An example of an entry for a static assigned IP address for the interface eth0:

auto eth0
iface eth0 inet static
        address 192.168.0.50
        network 192.168.0.0
        netmask 255.255.255.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        dns-nameservers 192.168.0.1

Additional IP address can be added with an extra section like

auto eth0:6
iface eth0:6 inet static
        address 192.168.0.56
        netmask 255.255.255.0

As can be seen above the additional network uses the same port eth0 with a colon and a reference number. Here it’s eth0:6.

With the new entry added to the file the networking can be restarted. To restart networking

/etc/init.d/networking restart

or

systemctl restart network