Thursday, May 16, 2013

Creating virtual network interfaces in RHEL/CentOS

Setting up an additional IP address for a webserver or any other service/reason is easy on RHEL/CentOS.

Go to /etc/sysconfig/network-scripts and copy existing script:
cp ifcfg-eth0 ifcfg-eth0:0
If you will need to create more IP addresses just increase the number after colon in the file name and in the device name field of course.

Now you need to edit ifcfg-eth0:0 and put there new IP address, it should have at least the following entries included:


Finally restart network services:
service network restart

You should be able to see new virtual interface up and running:
# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 08:00:27:18:08:b3 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
    inet brd scope global secondary eth0:0

No comments:

Post a Comment