Loading... <p>In this short post I will show you how you can quickly add a <strong>range of IPs</strong> on any <strong>RedHat </strong>based system (<strong>Rhel, Centos, Fedora</strong>, etc). When you have to add many IPs to a system this can be quite handy and save a lot of time.<br />Normally when you add a new IP to a network interface in a RedHat based system you create a file <strong>ifcfg-eth0:x</strong> in <strong>/etc/sysconfig/network-scripts/</strong>. For example:</p><blockquote><pre><code>/etc/sysconfig/network-scripts/<strong>ifcfg-eth0:0</strong>DEVICE=<strong>eth0:0</strong>ONBOOT=yesBOOTPROTO=staticIPADDR=192.168.0.100NETMASK=255.255.255.0NETWORK=192.168.0.0BROADCAST=192.168.0.255TYPE=Ethernet</code></pre></blockquote><p>Similar to the above example you can create several aliases. But what if you have to add a lot of IPs that are in a range like this? Let’s say that I want to add 100 IPs this way… this is possible, but not very effective, right? RedHat based systems offer a method to bind a range of IPs in a quick way allowing us to eliminate the need to create a lot of files and saving us time doing this.<br />Create a file <strong>/etc/sysconfig/network-scripts/ifcfg-eth0-range0</strong> if this doesn’t exist, or just add to it if you already have it, the following lines:</p><blockquote><pre><code>/etc/sysconfig/network-scripts/ifcfg-eth0-range0IPADDR_START=192.168.0.100IPADDR_END=192.168.0.200CLONENUM_START=0</code></pre></blockquote><p>where: <strong>IPADDR_START</strong> is the first IP and <strong>IPADDR_END</strong> is the last IP in the range. <strong>CLONENUM_START</strong> is the number that will be assigned to the first IP alias interface (eth0:0 in this example).</p><p>If you need to add more ranges of IPs then just use a different file for ex. <strong>ifcfg-eth0-range1</strong>, for each one of the ranges. You need to be careful and use the proper <strong>CLONENUM_START</strong> to not overwrite other aliases. Once you have configured the range/s of IPs you just need to restart the network service in order to activate it:</p><blockquote><pre><code>service network restart</code></pre></blockquote><p><em>Note</em>: don’t use this method on a <strong>CPanel based system</strong>. Even though this will work fine, it is better to use CPanel/WHM in this case so CPanel can manage all the IPs properly. Here is a <span class="external-link"><a class="no-external-link" href="http://www.ducea.com/2006/07/15/cpanel-adding-a-range-of-ips-using-whm/" target="_blank">short post<i data-feather='external-link'></i></a></span> on how you can do the same thing ‘CPanel way’.</p> <hr class="content-copyright" style="margin-top:50px" /><blockquote class="content-copyright" style="font-style:normal"><p class="content-copyright">版权属于:大漠孤狼</p><p class="content-copyright">本文链接:<a class="content-copyright" href="https://www.dmgls.com/412.html">https://www.dmgls.com/412.html</a></p><p class="content-copyright">转载时须注明出处及本声明</p></blockquote> Last modification:July 14th, 2020 at 11:53 am © 允许规范转载 Support 如果觉得我的文章对你有用,请随意赞赏 Appreciate the author