How to add a range of virtual IPs to a CentOS and
Fedora Linux server
Recently I had the task to add a range of few IP addresses to as a
virtual interface IPs.
The normal way to do that is of course using the all well known
ifconfig eth0:0, ifconfig eth0:1 or using a tiny shell
script which does it and set it up to run through
/etc/rc.local .
However the Redhat guys could omit all this mambo jambo and do it
The Redhat way TM by using a
standard method documented in CentOS and RHEL documentation.
Here is how:
# go to network-script directory [root@centos ~]# cd
/etc/sysconfig/network-scripts
# create ifcfg-eth0-range (if virtual ips are to be assigned on
eth0 lan interface [root@centos network-scripts]# touch
ifcfg-eth0-range
Now inside ifcfg-eth0-range, open up with a text editor or use the
echo command to put inside:
IPADDR_START=192.168.1.120
IPADDR_END=192.168.1.250
NETMASK=255.255.255.25
CLONENUM_START=0
Now save the
/etc/sysconfig/network-scripts/ifcfg-eth0-range
file and finally restart centos networking via the network
script:
[root@centos network-scripts]# service network
restart
That's all now after the network gets reinitialized all the IPs
starting with 192.168.1.120 and ending in 192.168.1.250< will
get assigned as virtual IPs for eth0 interface
Cheers ;)