How do I change the primary IP of my cPanel server? Print

  • 0

Log into the SSH (root). Open a terminal and start "screen". Modify /etc/wwwacct.conf file and replace the main IPv4 for the server. Once modified, verify the changes by running the command: cat /etc/wwwacct.conf

In the third step, you'll see ETHDEV ID is mentioned, note it down. Now, switch the directory: cd /etc/sysconfig/network-scripts/

Suppose, the ETHDEV ID was eth0, so you need to modify the ifcfg-eth0 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.

[ Please keep in mind, ETHDEV ID is not the same for all servers. It may be different for each server. So, you may check it by running the command in terminal: ls ]

Once this is done, change the main IP in /var/cpanel/mainip

[ If the new IP was previously added to the server through Home » IP Functions » Add a new IP address, remove it from /etc/ips or via the WHM interface at Home » IP Functions » Show or Delete Current IP Addresses. ]

You'll also need to fix the /etc/hosts file for the new IP.

Next, restart the network service and rebuild NAT with the build_cpnat script for the 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

You will likely get disconnected at this time and will need to log in again via the new IP address.

If the server has additional IP addresses, restart the ipaliases script to bring up the additional IPs:

service ipaliases restart

To verify the settings, run ifconfig to make sure everything shows up as expected, then update the cPanel license to the new primary IP and verify you can still log in to WHM without any warning.

Was this answer helpful?

« Back

Send Message