How to change the primary IP addres of a WHM/cPanel server

This is for Centos Based Systems

Steps in WHM:

  • Log into WHM and go to Basic cPanel & WHM Setup
  • Change the Primary IP here with the option that says "The IP address (only one address) that will be used for setting up shared IP virtual hosts"
  • Note: This might not actually be necessary.

Log in to SSH, and do the following:

  1. Edit /etc/sysconfig/network-scripts/ifcfg-eth0
    • Change the IPADDR and GATEWAY lines to match the new IP and Gateway for the new ip
  2. Edit /etc/sysconfig/network
    • Change the GATEWAY line here if it does not exist in the ifcfg-* file.
  3. Edit /etc/ips
    • Remove the new primary IP from this file if it is present
    • Add the old primary IP to this file with the format <IP address>:<Net Mask>:<Gateway>
  4. Edit /var/cpanel/mainip
    • Replace the old primary IP with the new primary IP
  5. Edit /etc/hosts
    • Replace the old primary IP with the new one if needed. The hostname's dns will need to be updated too
  6. Restart the network serviceto make the new IP the primary
    • service network restart
    • Note: You're probably going to be disconnected at this point, and have to log in to ssh using the new primary ip.
  7. Restart the ipaliases script to bring up the additional IPs
    • service ipaliases restart
  8. Run ifconfig and make sure all IPs show up correctly
  9. Update the cpanel license to the new primary IP
  10. Verify you can still log in to WHM and there is no license warning
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Accessing Website Stats without logging into cPanel

Accessing AWStats Outside of cPanel Accessing AWStats from outside the control panel is easy....

How can I enable Mod_Rewrite?

Recommended for Advanced Users Only What is mod_rewrite? This module provides a...

How do I access my clients' cPanel account?

Resellers can access their clients' control panel to make changes simply by substituting the...

I've forgotten my cPanel login. What do I do?

If you cannot remember your server login information, please submit a ticket with our staff and...

My Website Statistics have not Updated

Typically your web sites statistics are updated overnight. Occasionally, if the server has been...