Together with the Internet growth, service providers also evolved, being able to offer larger bandwidth and higher quality connections to their subscribers. Nowadays, almost anyone can get a high bandwidth connection and a class of IPs for a very low price compared to the costs from a few years ago. If you're one of the many people that turned their personal PCs into small servers that provide various services as a small company, then you know how important it is to have a few classes of IPs available. But then again, you should know how to bind a range of IPs to a Linux server so this guide is more for people that want to start a small business using their Linux systems but don't know which way to go. For instance, if you decide you want to turn your Linux system into a server and offer webhosting, mail, dns, ftp etc services, you'll need to know that each domain that will be hosted on your server will need its own unique IP. Not to mention the subdomains and any eventual custom services your clients will require. So before you start anything, you'll have to get a high bandwidth connection and a class of IPs. An IP address class can either be a Class C (245 addresses), a Class B (65,532 addresses) or a Class A (16,777,214 addresses). You decide what you need.
For a small range of IPs, you can manually add each IP to a file called ifcfg-eth0:x
, which resides in /etc/sysconfig/network-scripts/
. For instance, if you want to add 10 IP addresses, you'll have to create 10 files in that directory, starting with ifcfg-eth0:0
and ending with ifcfg-eth0:10
. Each file will contain:
will increase from 192.168.0.2
But what if you have to add 100 IP addresses? It could be physically possible to manually add a file for each of them. But how about 1000 IP addresses? Or 10,000? Fortunately, RedHat based systems offer a quick and easy way to bind a range of IPs, eliminating the need to create a lot of files and saving a lot of your time.
Create a file called ifcfg-eth0-range0
in the /etc/sysconfig/network-scripts
directory. This file must contain the following strings:
Let's see what each of them does:IPADDR_START
: This is the first IP from the address range you want to bind to your ethernet device.IPADDR_END
: This is, of course, the last IP from that address range.CLONENUM_START
: This is the number that will be assigned to the first IP alias interface. For instance, if your Internet interface is eth0 and CLONENUM_START is 0, then this config file will create 100 interfaces starting with eth0:0 (eth0:0, eth0:1, eth0:2 etc) and ending with eth0:100.NOTE!
Be careful if you need to add more ranges of IPs. You'll have to use a proper value for CLONENUM_START. For instance, if you need to add a second range with 100 IPs besides the one above, create a new file called ifcfg-eth0-range1
and set the CLONENUM_START to 101 so an overwrite will be avoided.
After making any changes to any of the files created in the network-scripts directory, you have to run the following command so the changes are applied and the address range is activated:# service network restart