How to add a secondary IP address on CentOS 7?

In this article we will show you how to add a secondary IP address to your server which is running CentOS 7. Adding an additional IP address is needed if you have two or more subnets and you need to use them on CentOS server. For doing it, you will need to add the second and multiple ip addresses to NIC. We remind you that a NIC (network interface controller) card is typically a circuit board that is installed on a computer to connect to the network.

Add an additional IP address Manually

Below we will show you step-by-step a way for adding an additional IP address to CentOS 7 manually

1. To get started, you need to log into your server using root rights. This will give you the opportunity to perform tasks with administrator rights.

2. Next we use the command

cd /etc/sysconfig/network-scripts/

This command will take you to the network configuration directory, which will allow you to edit network configuration files.

3. Use the command below to display the current interface settings


Pay attention to the file name. You can name new files according to your main interface. If the name of your main interface is eth0, then the names will be eth0:1, eth0:2, etc.

4. Next, we create our own configuration file for each additional IP address

nano ifcfg-eth0:1


(IPADDR and NETMASK data use those that you received when ordering an IP address)

Replace IPADDR in the line with the IP address you want to add

Now we added ip address to interface on CentOS

5. After the settings you need to save the changes using Ctrl+O and then exit Ctrl+X

6. Next step, restart the network service:

service network restart

7. In order to check that the changes have been made and everything is done correctly, use the command that you have already used before


And now we see that eth0:1 has appeared.

eth0:1 Link encap:Ethernet HWaddr 00:11:22:33:44:55
inet addr: Bcast: Mask:
Interrupt:185 Base address:0xa000


We have shown you one of the most common ways to add an additional IP address in CentOS. The difference with this method is that you do everything by hand. By following our instructions step by step, you can quickly add additional IP addresses in the future.

Our other articles: