Welcome to AUXNET IRC Network




Idle on AUXnet a lot? Why not play our idlerpg game, you can check it out at #idleRPG - for more information visit the website http://idlerpg.auxnet.org

Adding multiple ip ranges in Linux

Attention: open in a new window. PDFPrintE-mail

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

IP Block: 204.45.89.130-134
IP Block: 204.45.90.2-6
IP Block: 204.45.90.10-14
IP Block: 204.45.90.18-22
IP Block: 204.45.90.26-30

The above example has around 6 ranges with different ip sets. You can make use of the  ‘ ifcfg-eth0-rangeX ‘ feature to get this done simply. Ssh your server as root.

 

  • # cd /etc/sysconfig/network-scripts

Create a file named ifcfg-eth0-range0

 

  • # vi ifcfg-eth0-range0

Add the following lines as below to add the first set of range ( iee..204.45.89.130-134 )

 

ONBOOT=yes
IPADDR_START=204.45.89.130
IPADDR_END=204.45.89.134
NETMASK=255.255.255.248
CLONENUM_START=1

 

Save your works and exit. Restart the network service using ‘ service network restart ‘ . 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=204.45.90.2
IPADDR_END=204.45.90.6
NETMASK=255.255.255.248
CLONENUM_START=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.