Knowledgebase: Dedicated Hosting
Configuring/Adding a secondary/new IP address on a CentOS/Redhat server
Posted by Kayalvizhi S, Last modified by Ashish S on 18 June 2015 12:59:10 PM

If you have cPanel, then you can add additional IP addresses on the server by accessing the WHM panel using the following steps :-

1. Login to WHM panel.

2. Click on IP Functions.

3. click on Add a New IP Address and proceed accordingly.

For more details, please refer https://documentation.cpanel.net/display/1144Docs/Add+a+New+IP+Address

If you do not have cPanel addon purchased, you need to configure the secondary IP addresses manually from the command prompt using the following steps :-

Step 1 :

Go to the path '/etc/sysconfig/network-scripts/' by running the following command :

# cd /etc/sysconfig/network-scripts/

Step 2 :

On our servers, interface "eth0" is configured as the main adapter and you will see the corresponding file named "ifcfg-eth0" under the path "/etc/sysconfig/network-scripts/". So the first secondary IP address to be configured on the server has the file name as "ifcfg-eth0:0" and the next one as "ifcfg-eth0:1" and so on.

To know the secondary IP addresses configured on server, you can run this command :

# ifconfig | grep eth0

eth0 Link encap:Ethernet HWaddr 00:08:74:A3:29:70
eth0:0 Link encap:Ethernet HWaddr 00:08:74:A3:29:70
eth0:1 Link encap:Ethernet HWaddr 00:08:74:A3:29:70
.
.
.
eth0:5 Link encap:Ethernet HWaddr 00:08:74:A3:29:70

The output of the command looks similar to the one mentioned above.

Step 3 :

Create a new file using the correct file name as explained in Step 2 with the contents of the file "ifcfg-eth0". In the above mentioned example, you need to create the file name as "ifcfg-eth0:6".

Step 4 :

Now we have to configure this IP address to be : a static IP, no hardware address (MAC), configure netmask. You need to edit the file using the following details :-

# vim ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.1.1.1
NETMASK=255.255.255.0

Note : You need to specify the correct secondary IP address instead of "10.1.1.1" and device name in the above mentioned contents.

Step 5 :

Run the following command to restart the network:

/etc/init.d/network restart

Note : After the network has been restarted, new IP address should be visible by running the command "ifconfig".

You can ping the newly configured IP address using the command "#ping 10.1.1.1" and in-case you see any packet loss please contact our support team.

(2 vote(s))
Helpful
Not helpful