How to configure an IP range on Centos 6/7 OS

A guide that describes how to configure an IP range.

The following tutorial will describe how to easily configure an IP range on CentOS 6/7 operating systems.

Step 1 : check the network interface and assign IP

  #ifconfig & ip a

By default, all Linux servers are provided with one main IP address, as we can see in the screenshot below using the ip a”  command. Alternatively, you can use ifconfig”  command to see the output.

The IP range is configured on the main network interface. In this case, it’s called “eth0” , so we’ll bond the IP range with it.

Step 2 : Go to the path and create file


In linux network configuration is located at  /etc/sysconfig/network-scripts/ The main network interface configuration file is called ifcfg-$NET-ADAPTER-NAME In this case, it’s  ifcfg-eth0

Step 3 : Now we need to create the IP range file.

 #vi ifcfg-range0

To make the process easier, we’ll create an IP range file. This will allow us to configure multiple IP addresses with little work. Using your preferred text editor like “vi or vim” , in the path /etc/sysconfig/network-scripts  directory , create a file called  ifcfg-eth0-range0

Keypoint  – To add the second range you need to create another file called “ifcfg-eth0-range1” with the CLONENUM_START start with 300 (setting up the number in CLONENUM_START is very important here to avoid the ip overwritten

Using that information, let’s configure the IP range file on our operating system:

Save the changes and exit the text writer. If you’ve done everything correctly, you’ll see a new network configuration file has appeared in  /etc/sysconfig/network-scripts/  directory:

Step 4 : Check the create file


Step 5 : Lets restart the Network service.

Finally, restart the network service  using the below command and check the IP configuration again. The IP range is now fully configured:

#service network restart

#systemctl restart NetworkManager

Step 6 :  Add IP ranges temparory

#for i in {3..252}; do ip addr add 213.209.148.$i/24 dev eth0; done

KEY POINT –  there is one shortcut also available to add the multiple IP ranges with the help of below above script, using this script configure any  range in main network interface of the server, in my case main interface is “eth0”, but this configuration is temparory after the reboot server it will be not there.

#for i in {3..252}; do ip addr add 213.209.148.$i/24 dev eth0; done