How to manually bind a range of IPs in a linux server

In this article I will show you how you can quickly add a range of IPs in a linux server.Adding a range of ips is a very easy task. Nomally when you have added a new IP to a network interface in a RedHat based system it automatically creates a file ifcfg-eth0:x in /etc/sysconfig/network-scripts/. The value of x indicates that how many IPs you have added additionally, If you add 3 additional IPs there will be 3 additional files(eth0:1 to etho:3)

For example:

/etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.100
NETMASK=255.255.255.0
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
TYPE=Ethernet

Like the above example you can add many IPs as you want . But it will become difficult for you to add 100 IPs in this way. So there is a an alternate and easier way to do it RedHat based systems.

For example you have to bind a range of IPs starting from 111.111.111.111 to 111.111.111.222
Create a file /etc/sysconfig/network-scripts/ifcfg-eth0-range0 if this doesn’t exist, or just add to it if you already have it, the following lines:

/etc/sysconfig/network-scripts/ifcfg-eth0-range0
IPADDR_START=111.111.111.111
IPADDR_END=111.111.111.222
CLONENUM_START=0

where: IPADDR_START is the first IP and IPADDR_END is the last IP in the range we have added.

CLONENUM_START is the number that be assigned to the first IP alias interface (eth0:0 in this example). If you have to add another range then you have to create a fileifcfg- etho-range1 and so you have to specify  CLONENUM_START value as 1.

Finally restart the network daemon and you are done.
service network restart

Leave a Reply

Your email address will not be published. Required fields are marked *

*