Adding Virtual Network Interfaces on CentOS 5.x

Posted by on Oct 4, 2009 in Blog, linux | 5 comments

Recently at a client, I found myself consolidating two servers into one. Each server hosted their own array of services, a few of which overlapped. The first server was running a TFTP server, an HTTP web server, and an NTP time server. The second server, which would be the target server of the consolidation, was running it’s own TFTP server, an FTP server, and a DHCP server. The first thought was to reconfigure all of the clients that pointed at the first server’s IP address and point them to the second server’s IP address, but that would involve reconfiguring over 150 IP phones across two floors, most of which would have to be done by hand. Realizing that this wasn’t a very good option, I started looking for another solution.

In comes the idea of Virtual Network Interfaces, or assigning multiple IP addresses to the same physical interface. On Windows this is a pretty simple task, you just right-click the network interface, go to properties, go to the TCP/IP properties for your interface and then click Advanced – you’ll be given the option to add additional IP’s on the first screen. On a console-based Linux server, the approach is different, but still rather simple. In my example, the client was running a CentOS 5.3 server, but this will apply across many different Linux variants.

First you need to copy the file /etc/sysconfig/network-scripts/ifconfig-eth0 to /etc/sysconfig/network-scripts/ifconfig-eth0:1.

# cd /etc/sysconfig/network-scripts/
# cp ifconfig-eth0 ifconfig-eth0:1

Next, you need to open the new file (/etc/sysconfig/network-scripts/ifconfig-eth0:1) and change the #FILE, DEVICE, and IPADDR settings:

# File: ifcfg-eth0:1

Finally, you’ll need to restart your network service. Don’t worry if you’re doing this remotely, as long as you haven’t changed the settings for your original network file, you’re interface should come back up within a few seconds. Your terminal session may hang while the NIC reloads itself, but after that it will come back just fine.

# service network restart

That’s it!  If you’re consolidating two servers, like I was, you’ll want to make sure you take the old server off the network before you restart your network service or else you’ll have an IP address conflict on your hands, and nobody wants that!

5 Responses to “Adding Virtual Network Interfaces on CentOS 5.x”

  1. Having read this I believed it was extremely enlightening.

    I appreciate you spending some time and effort to put this content together.
    I once again find myself personally spending a lot of
    time both reading and posting comments. But so what, it was still worth it!

  2. Whoa! This may be one particular of the highest quality internet websites We have. ever before turn up throughout within this topic. In essence Good. Instant messaging furthermore a pro during this issue so we could recognize your. work.

  3. You’re truly a excellent webmaster. The web site loading velocity is incredible. It seems that you are doing any distinctive trick. Moreover, The contents are masterpiece. you’ve performed a excellent task on this topic!

  4. I do accept as true with all the ideas you have offered for your post.
    They’re really convincing and can definitely work. Nonetheless,
    the posts are too quick for starters. May just you please extend
    them a little from subsequent time? Thanks for the post.

  5. Everything is very open with a really clear clarification of the challenges.
    It was truly informative. Your website is extremely
    helpful. Many thanks for sharing!


  1. Delicious Bookmarks for May 12th from 01:58 to 23:30 « Lâmôlabs - [...] Adding Virtual Network Interfaces on CentOS 5.x | SelbyTech – May 12th ( tags: alias virtual network …

Leave a Reply