Add IP Range To CentOS

ifconfigIf you are looking for a quick way to add an ip range to your CentOS server use this script. The first thing you need to do is go over to the following directory:

cd /etc/sysconfig/network-scripts/

The next thing you have to do is create a new script named “ifcfg-eth0-range0”. You can do this by using the following command.

nano ifcfg-eth0-range0

Once you went ahead and created that file and its opened in nano or your favorite text editor you will need to add the following.

IPADDR_START=192.168.1.120
IPADDR_END=192.168.1.130
CLONENUM_START=0

The way CentOS attaches new ips is by adding devices for example eth:0 eth0:0 eth0:1 eth0:2 and so on. So the example above will start at eth0:0 and will stop at the last IP. The IPADDR_START and the IPADDR_END specify the range. In this example it will add 192.168.1.120 – 192.168.1.130. Replace this with your range you have been given by your datacenter. This is also known as your usable IPs. After you added this to the file save and close out the editor.

This guide assumes that you have already added the primary IP address to your server much like most web hosts provide when you are initially provisioned a server.

Once you have done all of the above you can make the changes take effect by issuing the following command:

service network restart

Note: This will disturb any download in progress.

After you have done that if you didn’t get any strange errors then you have successfully added an IP range to your servers. The only thing you have to do is execute a ifconfig to view all of the devices.

 

Ed

This entry was posted in Informational. Bookmark the permalink.