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.
Related Posts:
- [CYBER MONDAY] VirMach VPS Huge deals as low as $4/year! - November 27, 2017
- [CYBER MONDAY] HudsonValleyHost – $4.99/mo 5GB OpenVZ (normally $20/mo) and 40% OFF select items! - November 27, 2017
- [CYBER MONDAY] YourLastHost – Shared Hosting Specials! - November 27, 2017
Thanks a lot man!!! I used to do it the long way…… It works like a charm!
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!!
canbe used for centos7 +