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

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.

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How to fix IP Missing issue on cPanel/WHM

We are here to help you with solving the problem of Missing IP Server in list accounts. The...

Domain names are not showing in WHM

We were unable to see any domains listed under WHM -> List Accounts. However, we can see the...

How to Start/Stop or Restart Apache server

Apache is the HTTP server that is freely available over the internet. It is a kind of software or...

How to install Attracta SEO Tools plugin

RequirementscPanel/WHM needs to be installed on your server. Step 1: SSH into your server and go...

How to Install CpCleaner in cPanel through SSH?

Installation Run the following shell commands as root via SSH: wget -O cpc-1.0.3.tar...