How​ ​to​ ​​add​ ​an​ ​IP​ ​Range​ ​to​ ​your​ ​CentOS​ ​Server

In this howto guide we will be showing you how you can quickly create or bind a range of IPv4 addresses to your CentOS server.

This also works with any RedHat based system and even Fedora.

Whether you are needing to route a /26 IPv4 range, or a /24 IPv4 range – this method can save you lots of time, instead of binding each IP address manually, or creating hundreds of network
alias files.

In this example, we’ll be binding the IP Range, 123.123.123.0/24​ and assuming the first usable IP in this block (123.123.123.2) is already binded as the main IP of this node.

First, identify whether your main public network is utilizing ifcfg-eth0​ or ifcfg-eth1​.

For example:

 

#​ ​cat​ ​/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
HWADDR=0B:C3:7A:E1:6A:2C
ONBOOT=yes
NM_CONTROLLED=no
NOZEROCONF=yes
IPADDR=123.123.123.2
NETMASK=255.255.255.0
GATEWAY=123.123.123.1

 

 

Create a file /etc/sysconfig/network-scripts/ifcfg-eth0-range0 (change eth0 to eth1 if your
primary public network interface is configured on eth1, in this example, we assume eth0).

 

 

#​ ​nano​ ​/etc/sysconfig/network-scripts/ifcfg-eth0-range0

IPADDR_START=123.123.123.3
IPADDR_END=123.123.123.254
CLONENUM_START=0
NETMASK=255.255.255.0
ARPCHECK=no

 

 

IPADDR_START​ is the first​ IP of the range, in this case, we start at .3, since .2 is already
binded to the main interface. You will want to input the last usable IP of the range on
IPADDR_END​.

 

Additionally, you can use the proper CLONENUM_START​ to not overwrite other aliases that
might already be binded to the server. In the example above, if CLONENUM_START was set to
value “1” the first additional IP it would bind would start at .4, instead of .3.

 

Once you have configured the ranges of IPs that you wish to bind to your server, you do not
need to reboot the entire server, simply the network interface:

 

#​ ​service​ ​network​ ​restart

 

That's it, and you can verify the binded IPs by running ifconfig or ip a.

 

 

 

  • centos, ip range
  • 43 Users Found This Useful
Was this answer helpful?

Related Articles

How to change maximum upload size in php.ini

  There are a few common errors that occur in Wordpress and other PHP-based programs that use...

How to change the primary IP address of a cPanel server

Steps in WHM: Log into WHM and go to Basic cPanel & WHM Setup Change the Primary IP here...

How to install WordPress with Docker on Ubuntu 16.04

Before we start, it is necessary to install Docker and Docker Compose. On Ubuntu 16.04, this can...

How to Upgrade Kernel to Latest Version in Ubuntu

It is important to keep your systems up-to-date, here we'll show you how to upgrade your kenerl...

How to configure SQL server in Linux

Problem You installed SQL Server on Linux and need to customize the default installation, for...