Alias Interface and Multiple IP Addresses

Alias Interfaces:

In GNU/Linux, each Ethernet Network Interface Card (NIC) is linked with a network interface, which is named as eth0/eth1/eth2/.., and this interface can have one or more IP addresses associated with it. We can also create (using following command) multiple alias interfaces for a single real network interface (eth0). The alias interfaces are normally named like eth0:0, eth0:1, etc.

# ifconfig eth0:0 192.168.10.1 up
# ifconfig eth0:0 192.168.10.1 down

For a long time, I assumed that, we can create alias interfaces from 0 to 255 and only numbers can be used for alias names. But today I learned that, it was WRONG. We can use maximum of 10 alphanumeric characters for the alias name and we can create alias interfaces like eth0:cse, eth0:it, eth0:myteam, ..

# ifconfig eth0:abcdefghij 192.168.20.1 up
# ifconfig eth0:1234567890 192.168.30.1 up

This 10 characters limit, does not mean that, we can have millions of alias interfaces. There is a limit for this and don’t know the exact value for the GNU/Linux (2048 in some HP-UX). I hope, the limits in GNU/Linux will be around 1024.

Multiple IP Addresses:

The alias interface is not the only technique for having multiple IP addresses in a system. RTNetLink provide an another way to associate multiple IP addresses to a single interface (using following commands), with-out creating multiple alias interfaces.

Associate multiple IP addresses to a device:
# ip address add dev eth0 192.168.40.1/24 broadcast +
# ip address add dev eth0 192.168.50.1/24 broadcast +

Show the associated IP addresses (ifconfig won’t show this):
$ ip address show eth0

Delete the associated IP addresses:
# ip address delete dev eth0 192.168.40.1/24
# ip address delete dev eth0 192.168.50.1/24

For more information read: man ip

Advertisements
Tagged with: ,
Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: