LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

How​ ​to​ ​Quickly​ ​Bind​ ​an​ ​IP​ ​Range​ ​to​ ​your​ ​CentOS​ ​Server

lowendtutorial

In this short, yet informative tutorial, we will be showing you how you can quickly bind a range of IPv4 addresses to your CentOS server.

This also works with any RedHat based system, including 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

Volia! You’re all set, and you can verify the binded IPs by running ifconfig.

Special thanks to Julian Jin from AlphaRacks for sponsoring this tutorial.  

3 Comments

  1. Thanks a lot man!!! I used to do it the long way…… It works like a charm!

    October 14, 2017 @ 2:50 pm | Reply
  2. Tyler Morris:

    Great method! Thanks for the refresher lol, I remember doing this before but for the life of me couldn’t recall the commands/file names, till now!!

    October 15, 2017 @ 1:13 am | Reply
  3. ppopcn:

    canbe used for centos7 +

    October 16, 2017 @ 8:43 am | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

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