Menu

Tuesday, March 6, 2012

How to assign multiple IP addresses to a single Network Card Interface


Step 1: Find out how many physical NIC on the system
# ll /etc/sysconfig/network-scripts


Consider you have one Ethernet device "eth0" and would like to add more IP addresses (alias) for the same.

In this example, I have assigned "192.168.0.90" and "192.168.0.88" to my primary (physical) Ethernet device.
192.168.0.91 eth0    primary (Physical NIC)
192.168.0.90 eth0:1 alias1     (Virtual NIC)
192.168.0.88 eth0:2 alias2     (Virtual NIC)


Step 2: Copy the eth0 file

# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:2



Step 3: Edit the ifcfg-eth0:1 and ifcfg-eth0:2. Change the device name and the IP address.

# vim /etc/sysconfig/network-scripts/ifcfg-eth0:1

# vim /etc/sysconfig/network-scripts/ifcfg-eth0:2


Step 4: restart the network service

# service network restart








Step 5: Type ifconfig command to verify the network interface configuration and to check the all the IP addresses are running.

# ifconfig