Centos 6/RHEL create Virtual Static IP Addresses from one ethernet device

If you are using a standard ethernet device with a Static IP on your Cento 6/RHEL box then you can easily create additional Virtual Static IPs using the same device. These can enable you to run multiple servers and websites or create a private lan using a local IP and have the alias hold your Internet IP.

To do this you must first have a Static IP set up on your system, this assumes that you are just using one installed device and that you are familiar with the Static IP range available from your router.

First log in as root and copy your existing ifcfg-eth0 to a new file named ifcfg-eth0:1

# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1

This copies the original file and renames it to what will become a new virtual device. Open up the file in text editor.

# vi /etc/sysconfig/network-scripts/ifcfg-eth0:1

Vi and Vim commands

Scroll down and change the following two values

Device="eth0:1"
Name="System eth0:1"

Delete the whole of the following lines

HDWADDR=XX:XX:XX:XX:XX:XX
UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Now all that is left to do is to assign it a Static IP address from your available pool, scroll to the IPADDR section and enter the new address.

IPADDR=XXX.XXX.XXX.XXX

Save the file and restart the network

$ sudo service network restart

Now run ifconfig command to view the new Virtual Static IP

$ sudo ifconfig -a 


Virtual Static IP Centos 6
You can use the new Virtual Static IP address in a variety of ways, in addition you can add extra ones as long as you have the addresses available from your router, just ensure that they are named in succession, ie eth0:2 eth0:3 etc.



Labels: , ,