How to Change cPanel’s IP Address?

In this guide, we’ll walk you through the process of updating the main IP address for your cPanel server.

Introduction:
Before making any changes, it’s crucial to consult with your network or system administrator. Incorrect configuration may lead to server inaccessibility, and these modifications are not endorsed by Cpanel if the interface is not set up correctly.

The IP assigned to the network interface is utilized by cPanel. Since there’s no approval in the cPanel WHM interface, we recommend seeking assistance from your system administrator or network team.

To alter the primary IP address, you’ll need to use a command-line text editor to update the system’s network configuration file, cPanel’s MainIP file, restore NAT, and transfer your certification.

Follow these steps:

Log in to the “WHM” interface.

Navigate to the “Server Configuration” tab.

cpanel server configuration

Click on the “Basic cPanel & WHM” Setup button.

cpanel basic webhost manager

In the “The IP address (only one) that used for configuring shared IP virtual hosts” section, modify the main IP address. This action will update the file /etc/wwwacct.conf.

Then, via SSH, edit the IP address in the network configuration file. For instance, in a CentOS configuration, you would edit the /etc/sysconfig/network-scripts/ifcfg-interface name file and replace the old IP address with the new one.

Update the main IP in /var/cpanel/mainip via SSH, replacing the old with the new IP.

If the new IP was added previously through:
Home » IP Functions » Add a new IP address

Remove it from /etc/ips or via the WHM interface:
Home » IP Functions » Display or Remove Current IP Addresses

Additionally, update the /etc/hosts file to reflect the new IP address using the fixed host’s script:
/scripts/fixetchosts

To apply the changes, restart the network service and rebuild NAT with the build cpnat script. If your server doesn’t use NAT, the script will exit without an error.


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

Note: Disconnect at this point and log in again using the new IP address.

Restart the ipaliases script to bring up additional IPs if you have them:

service ipaliases restart

Verify the settings by running “ifconfig” to ensure everything is as expected. Update the cPanel license to the new primary IP and confirm you can log in to WHM without any warnings.

This completes the process of changing the IP for your WHM. If you encounter any issues following the outlined steps, please reach out to the host.co.in Team for assistance.