This article provides a guide for how to change the primary IP of a cPanel WHM server. This guide is intended for cPanel VPS and cPanel dedicated server users.
How to Change the Primary IP of a cPanel WHM Server
To change the primary IP of a cPanel WHM server, follow the steps below:
- Log into WHM as the 'root' user.
- Navigate to "Home / Server Configuration / Basic WebHost Manager Setup."
- Change the IP address set for "The IP address (only one address) that will be used for setting up shared IP virtual hosts" to the new IP address.
- SSH the server as 'root' user.
- Edit the server's network configuration to replace the old network configuration with the new network configuration.
Please note that the specific file or files to be updated depend on the OS the server is running and the network service running on the server. - Run the
/scripts/mainipcheckscript to update the main cPanel IP address. - Run the
/scripts/fixetchostsscript to update the /etc/hosts file. - Restart the network service.
On RHEL-based servers, run the following command:sudo systemctl restart network - Run the
/scripts/build_cpnatscript if your server is configured for NAT. - You will likely get disconnected at this time and will need to log in again via the new IP address.
- Run the
/scripts/restartsrv_ipaliasesscript if your server has additional IP addresses added through the "Home / IP Functions / Add a New IP Address" interface in WHM. - Run the
ifconfigcommand and verify that the correct information is shown. - Once the new IP is correct in your network configuration, make sure your license is updated to continue using WHM.
- Verify you can log in to WHM.
Conclusion
You now know how to change the primary IP of a cPanel WHM server.

👀 Choose SSD-powered VPS servers for increased speed, power, and security! Now 50% off- starting from only $3.19/mo.