Binding Multiple IP Addresses to a Single Network Interface Card (NIC)

December 12, 2009 by: Allen Sanford

500px-Ipv4_address.svgIn this tutorial I will be demonstrating how to bind multiple IP addresses to a single NIC. There are many different reasons for having multiple addresses binded to a single NIC; you could run a service under a specific IP while having another service running under a different one (for example, have HTTP on one and SMTP on another), or create a private LAN using a local IP and have the alias hold your Internet IP (such as NAT). Or in my case you can now have two DNS IP addresses to use to configure your windoze machines without having multiple machines. One of the major benefits is that you don’t need a physical adapter for each IP but instead you can create many virtual ones tied to a single physical card. The instructions provided apply to RedHat, Fedora, and CentOS. I’ll be using LAN IP’s from my network in this example, so you will need to replace them with IPs on your LAN.

The network scripts are located in /etc/sysconfig/network-scripts/. “cd” into that directory.

    cd /etc/sysconfig/network-scripts/

The file we’re interested in is ifcfg-eth0, this is the interface for the Ethernet device or card. If you have a second Ethernet card then there will be an ifcfg-eth1 file and so on for each adapter you have installed. We’ll assume that we are going to bind two additional IP’s (10.27.11.51, 10.27.11.52) to the NIC, this could be one or three or what ever you need. We will need to create two different alias files and leaving ifcfg-eth0 so it maintains its self as the primary IP address. The following table will explain what we are doing a little better.

Adapter IP Address Type
———————————–
eth0 10.27.11.50 Primary
eth0:0 10.27.11.51 Alias 1
eth0:1 10.27.11.52 Alias 2

The new adapters as you can see use :X (where X is the next available interface number) is appended to the interface file name to create the alias, are sequentiall and start at zero. For this example we will create aliases for eth0. Make a copy of ifcfg-eth0 for the two aliases.

    cp ifcfg-eth0 ifcfg-eth0:0
    cp ifcfg-eth0 ifcfg-eth0:1

Take a look inside ifcfg-eth0 and review the contents.

    cat ifcfg-eth0

We’re interested in only two lines (DEVICE and IPADDR). We’ll rename the device in each file corresponding to the interface alias and change the IP’s according to the table above. We’ll start with ifcfg-eth0:0. Open ifcfg-eth0:0 in vi and change the two lines so they have the new interface and IP address.

    vi ifcfg-eth0:0
    ...
    DEVICE=eth0:0
    ...
    IPADDR=192.168.1.111
    ...

Save ifcfg-eth0:0 and edit the other alias file ifcfg-eth0:1 so that it has a new interface and IP addresses set (again follow the table from above). Now that everything is set up you can restart the network service so everything will take effect.

    service network restart

To verify all the aliases are in fact up and running you can run “ifconfig” (depending on how many new IP’s you set up, you can use “ifconfig | more” to pause the output).

    ifconfig

You can also test the IP’s by pinging them from a different machine. If everything is working then there should be a response back.

    ping 10.27.11.50
    ping 10.27.11.51
    ping 10.27.11.52

Now one last order of business is to disable the and turn off the gnome Network Manager and then enable the network service so that the next time you boot up your net settings will take place. Run the following commands as root.

    chkconfig <a class="zem_slink" href="http://www.gnome.org/projects/NetworkManager" title="NetworkManager" rel="homepage">NetworkManager</a> off
    chkconfig network on

Everything should be working like a charm If you run into any problems during configuration, please post your questions to the comments below.

Enjoy and Have a Good’n!

Reblog this post [with Zemanta]

Filed under: Fedora
Tags: , , ,

Comments

7 Responses to “Binding Multiple IP Addresses to a Single Network Interface Card (NIC)”
  1. That was intriguing . I love your finesse that you put into your post . Please do continue with more like this.

  2. Very good blog. Continue to keep doing.|I saved this website. Appreciation for the great job!

  3. Mayhem says:

    Not a bad post whatsoever, would just have liked some more details and a few of the things explained a tad bit more.

  4. Hei, these dogs are interesting! You should take a look! Click this link: Crazy Dogs

  5. Hei, these dogs are humorous! You should take a visit! Click this link: Lol! Funniest Dogs

  6. hey, I uncovered some great posts you could possibly be interested to check out. Please stop by: Click here

Leave a Reply