Disclaimer: We highly recommend consulting with your network or system administrator prior to making any changes. Failing to configure the interface correctly can result in an unreachable server. cPanel is unable to assist with making any of these changes.
cPanel utilizes the IP assigned to the network interface. cPanel has no supported way to do this in the WHM interface and we strongly encourage you to reach out to your system administrator or network team to assist with making these changes. In order to change the primary IP, you must be familiar with a command-line text editor where you can update the systems network configuration file, cPanel's MainIP file, and rebuild nat as well as transfer your license.
From the WHM:
First, log in to the WHM interface and navigate to Home » Server Configuration » Basic cPanel & WHM Setup. Change the main IP in the section "The IP address (only one address) that will be used for setting up shared IP virtual hosts" This will update
Next, via SSH you need to change the IP in the network configuration file.
You can see a configuration example from CentOS here. Network configuration files
In order to change the IP, you will need to edit the
/etc/sysconfig/network-scripts/ifcfg-<interface_name> file and replace the old IP with the new IP on the line that looks similar to IPADDR=192.xx.xx.xx and GATEWAY= with the new correct gateway. The file name is going to be
Once this is done, change the main IP in
/var/cpanel/mainip by running the following script:
/scripts/mainipcheck. This will replace the old IP with the new IP configured.
If the new IP was previously added to the server through Home » IP Functions » Add a new IP address, you will need to remove this from /etc/ips or through the WHM interface Home » IP Functions » Show or Delete Current IP Addresses.
You'll also need to fix the
/etc/hosts file for the new IP. That can be done with the fixetchosts script.
Next, 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 at this time and will need to log in again with the new IP.
If you had additional IPs, restart the ipaliases script to bring up the additional IPs.
service ipaliases restart
To verify the settings run "ifconfig" to make sure everything showed up as expected and finally update the cPanel license to the new primary IP and verify you can still log in to WHM without any warning.
That will complete changing the IP for your WHM. To find out how to bulk change the IP for your accounts, please review How to change account IP addresses in bulk.