How to: Configure Additional IP Addresses on CentOS 7.x or Redhat 7.x


There are several different ways that you can enable IP addresses on CentOS/Redhat 7.x. In this guide, we’ll provide you with instructions and examples for configuring a small number of additional IP addresses, entire CIDR network prefixes (blocks/ranges), and ways to remove them.

Determining the Network Device Name

Before we can configure or remove any additional IP addresses, we will want to determine our primary network interface’s device name, which can be discovered by running the following command in our terminal:

[root@localhost ]# ip link | awk 'NR%2==1' | awk '{print $2,$8,$9}' | tr -d ':'

Its output should then be similar to below:

lo state UNKNOWN
enp3s0 state UP
enp4s0 state DOWN

The first device in the example above is named lo, which indicates that it is your loopback interface. The second line of output will typically be your primary network interface, and in this example it is. Its state is the only one currently UP (active/online), so we can assume that this is the correct interface to configure as the other is DOWN (disconnected/inactive). Should the other interface (eg: enp4s0) be configured and UP as well, you will then need to make a decision on which interface you prefer to have the additional IP space configured.

Locating the Network Configuration File

Using the output from the ip link command earlier, we can now locate the appropriate network configuration file in our network-scripts directory. Interface configuration files begin with ifcfg- followed by the interface’s device name. So, let’s review how everything is configured currently on our enp3s0 interface (replace with your interface’s name):

[root@localhost ]# cat /etc/sysconfig/network-scripts/ifcfg-enp3s0

Your output should look similar to below:


In the example above, the only IP address currently configured is It’s part of a /29 prefix (PREFIX=29), in which the IPs,,, and can be configured as well.

If your intention is to configure more than a few IP addresses on your network interface, then you’ll likely want to utilize a range file for configuration. A range file allows you to configure an entire CIDR network prefix (/29, /24. etc.), so you don’t have to configure each IP address individually. Continue onto the range file section or skip to the section for manually adding IP addresses if you only need to enable a small number of IPs.

Range File

First, let’s make an update to our primary network interface’s configuration file (replacing the interface name with yours):

[root@localhost ]# vi /etc/sysconfig/network-scripts/ifcfg-enp3s0

Now, append the following text to the end of the file and save it: NM_CONTROLLED=NO

This configuration change is required on Redhat/CentOS 7.x for enabling range files. It simply allows us to utilize range files by having the interface no longer be controlled by the Network Manager system. Once you’ve made the aforementioned change and saved the file, we can then proceed with creating our range file:

[root@localhost ]# vi /etc/sysconfig/network-scripts/ifcfg-enp3s0-range


There is no limitation on the amount of range files you can create, so if you have multiple ranges you wish to configure, simply create another range file (eg: ifcfg-enp3s0-range0, ifcfg-enp3s0-range1, etc.).

Add the following lines of text into your new configuration file (ifcfg-enp3s0-range). Replacing each parameter’s setting with your own unique network configuration (IPs, Prefix, etc.):

IPADDR_START= – The first usable IP address in the range.

IPADDR_END= – The last usable IP address in the range.

PREFIX=24 – The CIDR prefix for the block/range of IPs. (See the CIDR prefix table below to determine the correct prefix number for your range of IPs.)

CLONENUM_START=0 – The interface alias starting number, which will automatically increment by one for each additional IP address bound to the interface creating an alias for it (eg: enp3s0:0, enp3s0:1, etc.). If you have more than one range file, then you’ll want to ensure that this number is set to the next available number (eg: 253 if you have configured a /24 as described here).

It should look similar to the below range file:

CIDR Prefix Example Number of IPs
/32 1
/31 2
/30 4
/29 8
/28 16
/27 32
/26 64
/25 128
/24 256

In the example range file above, we’re configuring a /24 prefix, in which the first IP address ( is the Network address, the second being the Gateway address (, and the last IP address being the Broadcast ( address. These three IP addresses being “unusable” in the sense that they’re required to be configured in that manner for the rest of the IP addresses to work correctly. Optionally, you can configure a different Gateway as well should you need to use a different one than the default. If that is the case, then simply append GATEWAY=YOURGATEWAYADDRESS to the file as well. The current default Gateway address can be determined by running the following command:

[root@localhost ~]# ip route | grep default
default via dev enp3s0

Moving along, let’s double-check that we have input the correct information, and there are no errors in our range file. This is important because the next step can cause your server to become unreachable. After you have confirmed that everything is in order, restart the networking services for the changes to take effect:

[root@localhost ]# systemctl restart network

Then ping them individually after the restart command has finished to confirm they’re working as expected:

[root@localhost ]# ping -c 4
[root@localhost ]# ping -c 4
[root@localhost ]# ping -c 4

Alternatively, you can utilize software to ping a range of IPs such as fping. To install fping, you’ll need to find an RPM repository that includes fping and enable the repository, and then install it that way. If you’d rather just compile it from source, then you can do so by running the following commands:

[root@localhost ]# yum install gcc wget -y
[root@localhost ]# wget
[root@localhost ]# tar -xzvf fping-3.10.tar.gz && cd fping-3.10.tar.gz
[root@localhost ]# ./configure && make && make install

Then run the fping command against the range of IP addresses using CIDR notation:

[root@localhost ]# fping -g

Or the beginning and ending IPs in the range:

[root@localhost ]# fping -g

If everything is responding then you’ve sucessfully configured your additional IP addresses.

Manually Adding IP Addresses

Depending on the amount of IPs you’re configuring, it may be easier to just add them manually. Adding a small number of IPs can be completed by either adding them to your main network interface configuration file or by using the ip command. Let’s cover the permanent method first by updating our network interface configuration using the following command (replacing enp3s0 with your interface name):

[root@localhost ]# vi /etc/sysconfig/network-scripts/ifcfg-enp3s0

Assuming that you already have at least one IP address configured (eg: from your range as IPADDR=, you can append then following lines to your configuration file to enable your four additional usable IP addresses from your /29:


Restart the network for the changes to take effect:

[root@localhost]# systemctl restart network

Lastly, check that they’re working as expected:

[root@localhost ]# ping -c 4
[root@localhost ]# ping -c 4
[root@localhost ]# ping -c 4
[root@localhost ]# ping -c 4

If they all respond, then you’ve successfully configured the IP addresses.


IPs added through the method below will not be available after a network service or system restart. If you would like the changes to be permanent, then use the method above instead.

To add IPs using the ip command, use the following command and replace the variables inside the brackets with your information:

[root@localhost ]# ip addr add [IP or IP/Prefix] dev [network_device_name] label [network_device]:[alias_number]


[root@localhost ]# ip addr add dev enp3s0 label enp3s0:0

Check that it’s working:

[root@localhost ]# ping -c 4

If you’re able to ping it, then it has been added successfully.

Removing IP Addresses

Now that we know how to add additional IP addresses, let’s quickly go over how you can remove them.


IPs removed through the methods below will only temporarily remove them. A network service or system restart will re-add the IPs if they were set via a configuration file originally. Should you want to permanently remove the IPs, then you will need to update your configuration file(s) accordingly.

To remove a single IP address, you can issue the following command:

[root@localhost ]# ip addr del [ipaddress] dev [network_device_name]


[root@localhost ]# ip addr del dev enp3s0

If you would like to remove an entire range, you can do so by flushing the IPs with the following command:

[root@localhost ]# ip -s a f to [CIDRPrefix]


[root@localhost ]# ip -s a f to