How do you assign an additional IP to a NIC?
Print 
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 192.168.1.1 and you also want it to listen to IP 192.168.1.2. 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:

In this case, the original lines would be:

DEVICE=eth0
...
IP=192.168.1.1

You want to edit them to read:

DEVICE=eth0:2
...
IP=192.168.1.2

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:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0 ... eth0:2 Link encap:Ethernet ... inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 ...
Tags