At Monovm we provide you with the underlying facts, assumptions and rules which a computer system has.

01

Jan, 19

How to add an extra IP to CentOS 7?

  • by Sophia H
  • in VPS
  • View 141

Sometimes you need to add more than one IP to a NIC (Network Interface Controller), this situation occurs when you need to support two or more separate networks with one server. In this article, we are going to add an extra IP to one NIC in CentOS 7.

At first, we need to know the NIC name, to do this log in as root user and insert this command

ip a

The output sample is like below

c1

As you see in the output, the NIC name is eno16777984 and the IP is 185.94.191.114

To change the NIC IP or to add more IPs, we should open the “/etc/sysconfig/network-scripts/eno16777984” file with one editor as below command:

vi /etc/sysconfig/network-scripts/ifcfg-eno16777984

Note that eno16777984 is my server’s NIC name and it is different in your server

The output is like:

c2 

Now press ‘i’ to edit the file and enter the new IP address that you want to add as IPADDR1 like the below picture. If this new IP is in a different subnet, enter the gateway and subnet mask as GATEWAY1 and PREFIX1.

Note that Prefix means the number of ‘1’ in the subnet mask.

 c3

After editing the file, press ‘esc’ and then type the ‘:wq’ to save and exit the file.

Now restart the network by this command

/etc/init.d/network restart

That’s all you need to add extra IP to your server’s NIC on CentOS 7

Enjoy it…

 

 

 

 

 

 

 

 

 

 

Sophia H

My name is Sophia H. My degree is MS in Information Technology Engineering. I have been working for 5 years on Java developing (j2ee), Computer Networking (Optical Networks), Virtualization and Hosting.