Comments None

Following up our previous articles about how to Add an Additional IP Address and Adding A Range of IP Addresses in CentOS we’ll now see how to add a range of IP addresses under Debian. As previously mentioned there is no easy, standard way to do so, that’s why we’re going create a small script that will automate the job for you.

#!/bin/bash for ip in {1..254}; do echo up ip addr add 192.168.1.$ip/24 dev eth0>>/etc/network/interfaces done

Once you create the file, don’t forget to set execute permissions for the file.

chmod 755

Keep an eye on the netmask /24 which may be different in your case. The script will append data in your /etc/network/interfaces file so running it twice may not be a desired behavior.

Within the next article we’ll present a similar script that will allow you to add IP addresses from a specific list, not necessary sequential.

Comments None

Debian based systems doesn’t provide an easy way to add a range of IP addresses. Under CentOS this can be achieved by creating a special file under /etc/sysconfig/network-scripts. For each range of sequential IP addresses, create a file named ifcfg-ethX-rangeY, replacing X with your network interface and Y with a sequential number starting with 0, e.g. ifcfg-eth0-range0.


There are starting IP and ending IP which are self explanatory. Note the COLENUM_START configuration parameter which specifies the starting alias. In this example it will create a total of 10 aliases named eth0:0 … eth0:9.

If you’d like to specify another range, you have to properly calculate the value for the next COLENUM_START, e.g. creating ifcfg-eth0-range1 will look like:


Once you’re done with the configuration, you can start the new IP addresses by typing:

/etc/sysconfig/network-scripts/ifup-aliases eth0

Comments 1

There are a lot of reasons you may want to add an additional IP under your Linux dedicated or VPS server. In most cases your hosting provider shall be able to allocate and route additional IP address on request. When you request a new IP it’s quite possible to be asked about the purpose you’re going to use it for, known as justification. Additional IPs will cost you a couple of more bucks and the price depends from provider to provider. Once your request is accepted the IP will be routed to your server and you’re ready to go. Now you have to configure the new IP under your linux box. Depending on the linux distribution used the steps are slightly different.

For both Debian and CentOS you have to define network interface aliases.


Under Debian edit your /etc/network/interfaces file and add a code block like the one below containing the alias, the IP address and the netmask. Note you cannot specify gateway and dns-nameservers for an alias. The example below adds an IP address with alias eth0:0 and IP


auto eth0:0 iface eth0:0 inet static address netmask


With CentOS you have to create a new file for each IP you’d like to define under /etc/sysconfig/network-scripts directory. The file have to be named ifcfg-eth0:X where X is the alias number starting from 0 and eth0 is the actual network interface.



You can bring up all the additional IPs by calling:

/etc/sysconfig/network-scripts/ifup-aliases eth0

← Older Newer →