The concept of creating or configuring multiple IP addresses on a single network interface is called IP aliasing. The main advantage of using this IP aliasing is, you don’t need to have a physical adapter attached to each IP, but instead you can create multiple or many virtual interfaces (aliases) to a single physical card.
To assign multiple ip addresses on a snigle interface, first of all we need to identify the default interface for the Ethernet device. Suppose the interface name is "
ifcfg-eth0" and we want to create three additional virtual interfaces to bind three IP addresses
10.20.30.20, 10.20.30.30, and 10.20.30.40.
So, we need to create three additional alias files, while "ifcfg-eth0" keeps the same primary IP address.
Adapter IP Address Type
-------------------------------------------------
eth0 10.20.30.10 Primary
eth0:0 10.20.30.20 Alias 1
eth0:1 10.20.30.30 Alias 2
eth0:2 10.20.30.40 Alias 3
Where "
:X" is the device (interface) number to create the aliases for interface eth0. For each alias you must assign a number sequentially. For example, we are copying existing parameters of interface "
ifcfg-eth0" in virtual interfaces called
ifcfg-eth0:0, ifcfg-eth0:1 and ifcfg-eth0:2. Go into the network directory and create the files as shown below.
# cd /etc/sysconfig/network-scripts/
# cp ifcfg-eth0 ifcfg-eth0:0
# cp ifcfg-eth0 ifcfg-eth0:1
# cp ifcfg-eth0 ifcfg-eth0:2
Open the file "ifcfg-eth0" and view the contents.
#cat ifcfg-eth0
DEVICE="eth0"
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.20.30.10
Then we need to make changes for two parameters (DEVICE and IPADDR) in aliases files "ifcfg-eth0:0", "ifcfg-eth0:1" and "ifcfg-eth0:2"
Here is the
ifcfg-eth0:0 file after making the necessary changes.
#cat ifcfg-eth0:0
DEVICE="eth0:0"
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.20.30.20
Similarly make the changes in remaining files (
ifcfg-eth0:1 and
ifcfg-eth0:2).
Once, you’ve made all changes, save all your changes and restart the network service for the changes to reflect.
# /etc/init.d/network restart
That's all ...