How to change main IP of the server cPanel/WHM

If you are using a cPanel/WHM interface to manage the web hosting, some changes are needed to be done if the main IP address of the server got changed due to some reason. Here I am providing the steps to be done at the WHM panel after an IP change is done at the server-side. You can watch the video tutorial by clicking on this link.

  1. The WHM will be accessible with the new IP address using port 2087 if there is no specific firewall restriction is applied on the server to block the new IP.
  2. Once logged in, the first thing to be changed is the 'shared IPv4 virtual hosts' option from the Home »Server Configuration »Basic WebHost Manager Setup.



  3. Then you can manage the added IP addresses via Home »IP Functions »Show or Delete Current IP Addresses. You can remove the old IPs from here and also add if you have more IPs using the Home »IP Functions »Add a New IP Address option.

These are the major changes to be done inside the WHM panel. But we also have to make a few changes via the command line as well.

1. Change the main IP in /var/cpanel/mainip, replacing the old with the new IP.

2. Then you need to fix the entries in the '/etc/hosts' file. Either you can do it manually or using the cPanel script '/scripts/fixetchosts'.

3. Next, we need to restart the network service and rebuild NAT with the build_cpnat script for those changes to take effect. If the server is not using NAT, the build_cpnat script will exit cleanly. 

# service network restart && /scripts/build_cpnat > /dev/null 2>&1

Please note you will likely get disconnected from the server at this time and will need to log in again with the new IP.

4. If you had additional IPs, restart the 'ipaliases' script to bring up the additional IPs to the interface using the 'service ipaliases restart' command.

5. Make sure that all configuration is good using the 'ifconfig' command and also remember to change the license IP to the new one as well. 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

cPanel: Apache-FastCGI Data Timeout Error

If you are using a cPanel server and have FastCGI enabled in Apache, you might be facing the...

Domainkey installer in cPanel

You can use the following cPanel script to install domainkey for an account...

Email issues :: Common Troubleshooting Steps

Here I will discuss some common errors and their solution: We are using a mail relay setup for...