6.7. IP aliasing

There are some applications in which it is useful to configure multiple IP addresses to a single network device. The ISPs (Internet service providers) frequently use this characteristic to provide personalised features (such as World Wide Web and FTP) to their users. For this, the kernel must be compiled with the Network Aliasing and IP (aliasing support) options. After installing the new kernel, the configuration is very easy. The aliases are attached to the virtual network devices associated with the new device with a format such as: device: virtual number.

For example: eth0:0, ppp0:8

Let us say that we have an Ethernet network that supports two different IP subnets simultaneously and that our machine wants to have direct access to them. An example of the configuration would be:

ifconfig eth0 192.168.110.23 netmask 255.255.255.0 up
route add -net 192.168.110.0 netmask 255.255.255.0 eth0
ifconfig eth0:0 192.168.10.23 netmask 255.255.255.0 up
route add -net 192.168.10.0 netmask 255.255.255.0 eth0:0

Which means that we would have two IPs, 192.168.110.23 and 192.168.10.23 for the same NIC. In order to delete an alias, add a '-' at the end of the name (for example, ifconfig eth0:0- 0). [Mou01, Ran05]

A typical case is when we wish to configure a single Ethernet card so that it acts as the interface for different IP subnets. For example, suppose we have a machine that is on a LAN network, LAN 192.168.0.x/24. And we wish to connect the machine to the Internet using a public IP address provided with DHCP using the existing Ethernet card. For example, we can follow the procedure described in the preceding example or edit the /etc/network/interfaces file so that it includes a section similar to the following:

iface eth0 inet static

address 192.168.0.1

netmask 255.255.255.0

network 192.168.0.0

broadcast 192.168.0.255

iface eth0:0 inet dhcp

The eth0:0 interface is a virtual interface and its parent interface, eth0, will activate when it does.