Problem
The following document will outline the steps needed to assign multiple IP addresses to a single interface on CentOS 6. This process is called IP aliasing. You can make temporary or permanent IP aliases, but we will be focusing on making permanent aliases.
tl;dr
cd /etc/sysconfig/network-scripts/ cp ifcfg-eth0 ifcfg-eth0:1 sed -i "s/DEVICE=eth0/DEVICE=eth0:1/" ifcfg-eth0:1 sed -i "s/IPADDR=[Your primary IP]/IPADDR=[Your secondary IP]/" ifcfg-eth0:1 ifup eth0:1
Solution
Creating an IP alias is very simple. First, lets create a new file in the network-scripts directory using your favourite editor.
vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=none
IPADDR=[Your secondary IP]
NETMASK=[Your netmask]
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
Now that we have created the file, turn on the interface
ifup eth0:1
- Updated