How to add multiple IP range in RHEL/CentOS 6

For example, if you want to add the following different ip pool ranges in the server on the Ethernet port eth0. Here are few simple steps to add the ip pool ranges in few minutes.

IP Pool Block: 192.168.10.2-6
IP Pool Block: 192.168.10.10-14
IP Pool Block: 192.168.10.18-22
IP Pool Block: 192.168.10.26-30
IP Pool Block: 192.168.10.130-134

The above example has around 5 ranges with different ip sets. You can make use of the “ifcfg-eth0-rangeX” feature to get this done simply.

1. SSH the server as root Login.

# cd /etc/sysconfig/network-scripts/

2. Create a file named ifcfg-eth0-range0

# nano ifcfg-eth0-range0

Add the following lines as below to add the first set of range (ie..192.168.10.2-6)

ONBOOT=yes
IPADDR_START=192.168.10.2
IPADDR_END=192.168.10.6
NETMASK=255.255.255.248
CLONENUM_START=1

3. Save your works and exit. Restart the network service.

# /etc/init.d/network restart

4. To add the second range you need to create another file called “ifcfg-eth0-range1” with the CLONENUM_START start with 5 (setting up the number in CLONENUM_START is very important here to avoid the ip overwritten, as the first range will use up to the eth0:4 the second range should start with eth0:5 to work properly).

ONBOOT=yes
IPADDR_START=192.168.10.10
IPADDR_END=192.168.10.14
NETMASK=255.255.255.248
CLONENUM_START=5

5. Save your works and restart the network service. You can do the same for the other ip ranges left with carefully numbering the CLONENUM_START. Use the ifconfig command to check the eth0:X number everytime you restarts. After adding all the ranges, use ping to check the ips to make sure they are added properly.

ONBOOT=yes
IPADDR_START=192.168.10.10
IPADDR_END=192.168.10.14
NETMASK=255.255.255.248
CLONENUM_START=10

6. So on …

 
 


Was this article helpful?

mood_bad Dislike 3
mood Like 0
visibility Views: 16928