Virtual ip is an ip that bind to a physical ethernet card that already have physical ip address. To set virtual ip in centos, follow the below steps:
1. We will add virtual ip to eth0. Below is original configuration of /etc/sysconfig/network-scripts/ifcfg-eth0. ifcfg-eth0 is the original configuration file for eth0.# vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static
BROADCAST=192.168.0.255
HWADDR=00:0C:29:C8:AA:7C
IPADDR=192.168.0.10
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
TYPE=Ethernet
# cd /etc/sysconfig/network-scripts
# cp ifcfg-eth0 ifcfg-eth0:0
# vi ifcfg-eth0:0
BOOTPROTO=static
BROADCAST=192.168.0.255
IPADDR=192.168.0.11
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
TYPE=Ethernet
3. Restart network
# /etc/init.d/network restart
4. Check your new virtual ip using ifconfig
# ifconfig
4 comments:
thanks for your article.
wellnux.
http://blog.shareyourmenu.com
"ONBOOT=yes" should more correctly be as follows across the eth0 and eth0:0 pairs,
/etc/sysconfig/network-scripts/
ifcfg-eth0
ONBOOT=yes
ifcfg-eth0:0
ONPARENT=yes
So basically you need minimal?
BOOTPROTO=static
IPADDR=192.168.0.11
NETMASK=255.255.255.0
TYPE=Ethernet
ONBOOT=yes
So apparently ONPARENT is also advised instead of ONBOOT?
I myself kept the option DEVICE=eth0:x in place.
how about if I set virtual ip is different ip address segment with default(physical). Is it possible? and how?
Post a Comment