How do you assign an additional IP to a NIC?

There are cases where you need more than one IP on a server. How do you assign a second IP to a Network Interface Card?

In Redhat-based distributions there is a directory, /etc/sysconfig/network-scripts/, that contains configuration files for each network device (such as ifcfg-eth0 for the first ethernet card.)

The easy way to assign a second IP to one of these cards is to make a copy of the file, alias the device name and change the IP. For example: Let's say that eth0 is configured for the IP and you also want it to listen to IP Here's what you do:

First, cd to the network-scripts directory:

# cd /etc/sysconfig/network-scripts/

Next, make a copy of the configuration file:

# cp ifcfg-eth0 ifcfg-eth0-2

Now edit the file. There are only two lines that you really need to change:

  • You need to update the device= line to give an alias name to the device and
  • You need to change the IP= line to reflect the desired IP.

In this case, the original lines would be:


You want to edit them to read:


That's all! Save your changes and restart your network:

# service network restart

Now, when you check your network configuration you will find an extra device with the new IP:

eth0 Link encap:Ethernet ... inet addr: Bcast: Mask: ... eth0:2 Link encap:Ethernet ... inet addr: Bcast: Mask: ...