How To Add Secondary IP / Alias On Network Interface in RHEL / CentOS 7

Mattias Geniar, Sunday, August 2, 2015 - last modified: Monday, August 24, 2015

This guide will show you how to add an extra IP address to an existing interface in Red Hat Enterprise Linux / CentOS 7. There are a few different methods than on CentOS 6, so there may be some confusion if you're trying this on a CentOS 7 system for the first time.

First, determine if your network interfaces are under the control of the Network Manager. If that's the case, you'll want to keep using the Network Manager to manage your interfaces and aliases. If it's not under Network Manager control, you can happily modify your configs by hand.

View your IP Addresses

The "old" days of Linux used to be all about ifconfig. It would show you all interfaces and their IP aliases on the server. In CentOS/RHEL 7, that's not the case. To see all IP addresses, use the ip tool.

$ ip a | grep 'inet '
    inet scope host lo
    inet brd scope global dynamic eth0
    inet brd scope global dynamic eth1

This syntax is more inline with most routers/switches, where you can grep for inet and inet6 for your IPv4 and IPv6 IP addresses.

$ ip a | grep 'inet6 '
    inet6 ::1/128 scope host
    inet6 fe80::a00:27ff:fe19:cd16/64 scope link
    inet6 fe80::a00:27ff:fefd:6f54/64 scope link

So remember: use ip over ifconfig.

Using Network Manager

Check if your interface you want to add an alias to, uses the Network Manager.

$ grep 'NM_CONTROLLED' /etc/sysconfig/network-scripts/ifcfg-ens160

If that's a yes, you can proceed with the next configurations using the Network Manager tool.

You may be used to adding a new network-scripts file in /etc/sysconfig/network-scripts/, but you'll find that doesn't work in RHEL / CentOS 7 as you'd expect if the Network Manager is being used. Here's what a config would look like in CentOS 6:

$ cat ifcfg-ens160:0

After a network reload, the primary IP address will be removed from the server and only the IP address from the alias interface will be present. That's not good. That's the Network Manager misinterpreting your configuration files, overwriting the values from your main interface with the one from your alias.

The simplest/cleanest way to add a new IP address to an existing interface in CentOS 7 is to use the nmtui tool (Text User Interface for controlling NetworkManager).

$ nmtui


Once nmtui is open, go to the Edit a network connection and select the interface you want to add an alias on.


Click Edit and tab your way through to Add to add extra IP addresses.


Save the configs and the extra IP will be added.

If you check the text-configs that have been created in /etc/sysconfig/network-scripts/, you can see how nmtui has added the alias.

$ cat /etc/sysconfig/network-scripts/ifcfg-ens192
# Alias on the interface

If you want, you can modify the text file, but I find using nmtui to be much easier.

Manually Configuring An Interface Alias

Only use this if your interface is not controlled by Network Manager.

$ grep 'NM_CONTROLLED' /etc/sysconfig/network-scripts/ifcfg-ens160

If Network Manager isn't used, you can use the old style aliases you're used to from CentOS 5/6.

$ cat ifcfg-ens160:0

Bring up your alias interace and you're good to go.

$ ifup ens160:0

Don't use this if Network Manager is in control.

Adding a temporary IP address

Want to add an IP address just for a little while? You can add one using the ip command. It only lasts until you reboot your server or restart the network service, after that -- the IP is gone from the interface.

$ ip a add dev eth0

Perfect for temporary IPs!

Hi! My name is Mattias Geniar. 👋 I'm an independent software developer ⌨️ & Linux sysadmin 👨‍💻, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear! Follow me on Twitter as @mattiasgeniar 🐦.

🔥 If you're stuck with a technical problem, I'm available for hire to help you fix it!

Share this post

Did you like this post? Help me share it on social media! Thanks. 🤗

Have feedback?

New comments have been disabled on this blog, existing comments will remain as-is. Want to give feedback? Is there a mistake in the post?

Send me a tweet on @mattiasgeniar!


Jim Jenkins Thursday, January 12, 2017 at 16:51 -

Much obliged. I have a PC with an iffy network card, so eth0 doesn’t alway come up. Used your last command to add the missing address as an alias to lo.

Chad Saturday, February 11, 2017 at 01:43 -


Having a hard time here. Trying to bind 8 x /25 subnets (in addition to primary /29) to my Centos 7 box.

I have

ifcfg-em1 (primary /29)

ifcfg-em1-range0 (2nd /25 which pings)

ifcfg-em1-range0:0 (doesn’t ping after network restart).

I also tried: ifcfg-em1-range1 (doesn’t ping either).

The range files look like this:

iontcs Monday, February 4, 2019 at 13:44 -

after add the device, you must to activate it with “ifup eth1”

Francisco Bravo Saturday, July 6, 2019 at 01:16 -

Thanks, my server is working now

Shital Friday, July 19, 2019 at 09:41 -

If there is no such option “NM_CONTROLLED” mentioned in interface file , then what need to be done to add alias in RHEL 7
Can we use traditional mentioned of adding file interface:0 under /etc/sysconfig/network-scripts/ and ifup interface:0 if “NM_CONTROLLED” not mentioned in interface file in RHEL 7 ?..

Inbound links