Add secondary IP address (static) to CentOS server.

In this article, I am going to show you how to bind an additional IP address to your cloud server running CentOS operating system.

Please click the thumbnails to enlarge the image.

01 – First, log in to your server as root at the console or via SSH. It is better to log in via the console.

02 – Before we bind the new IP address, you may want to take a look at the existing IP address bindings by entering the “ifconfig” command at the prompt. In our example here, you will find an IP address is already binded to the network interface eth0.

03 – Now, run the following command

nano /etc/sysconfig/network-scripts/ifcfg-eth0:1

to create and edit the new secondary network interface configuration file.

04 – The command from the last step should open an text based editor. Just enter the network information as shown below and save the file.


DEVICE: This is name of the interface you are going to assign the IP to. The information after the equal sign should equal to the file name.
BOOTPROTO: “static” means the IP address is statically assigned to the server rather than dynamically.
ONBOOT: Enter “yes” on this line mean the sever will bind this IP when boot.
IPADDR: This is where you enter you IP Address. Your IP address should be different from the example listed.

Once you finish entering the information, you can press “CTRL-X” to exit the editor. And the editor will ask you whether you like to save the file or not. Just hit “Y” for yes.

05 – Once you save the file , exit and back to the command prompt, you need to restart the network service in order to bind the new IP address. You can do so by entering the following command at the command prompt.

service network restart

Note: Of course, you can reboot the server if you like, but restarting the network service is all you need. If you are accessing the server via SSH instead of console, you MAY be disconnected when you restarting the network service. If you are disconnected from the server, just re-established the connection again.

06 – If you are at the console, your screen output may look similar to this image. First, the server will shut down the network interface and bring it backup. The new IP address will be binded when interface eth0 is up.

07 – If you want to see if the new IP address is binded or not, just issue the command “ifconfig” at the prompt again. As you can see in our example, there are 2 interfaces with eth0 binded with the original IP while the newly created interface eth0:1 binded with the new IP address.

This entry was posted in 11 - General Services, CentOS Linux. Bookmark the permalink.

Comments are closed.