Add IP Address Range to Your Server (CentOS/Ubuntu/Debian)

Updated on October 18, 2016
Add IP Address Range to Your Server (CentOS/Ubuntu/Debian) header image

Introduction

In this tutorial, we will cover the process of adding an entire IP range/subnet to a Linux server running CentOS, Debian, or Ubuntu. The process is rather simple and takes no more than 10 minutes to complete.

CentOS

Using your favorite text editor, create or edit /etc/sysconfig/network-scripts/ifcfg-eth0-range0 (eth0 being the default adapter, make sure to use the correct adapter name) and add the following lines:

IPADDR_START=
IPADDR_END=
CLONENUM_START=0
NETMASK=255.255.255.0

What you want to do is replace the IPADDR_START variable with the beginning of your IP range, and IPADDR_END respectively.

It should look like the following after filling the variables (the variables are filled with an example /24 block, or 256 addresses):

IPADDR_START=192.0.2.0
IPADDR_END=192.0.2.256
CLONENUM_START=0
NETMASK=255.255.255.0

Note: The netmask depends on the subnet size. You can use Vultr's Subnet Calculator.

Save the configuration and close the file.

Restart the networking service:

/etc/init.d/network restart

or:

service network restart

Debian/Ubuntu

Using your favorite text editor, open /etc/network/interfaces.

Add the following (192.0.2.0 being the example address):

iface eth0 inet static
address 192.0.2.0/24

Exit and save. Now, reboot the system:

shutdown -r now

You should be able to see the addresses under the interface by running the following command:

ip addr

This concludes our tutorial. Thank you for reading.