Changing the primary IP address of a cPanel server can be a crucial task, whether you’re migrating to a new server, updating your network configuration, or replacing an old IP. This guide will walk you through the entire process, ensuring a smooth transition with minimal downtime.
Steps to Change cPanel Primary IP in WHM
Step 1: Update Primary IP in WHM
- Log into WHM (Web Host Manager).
- Navigate to Basic cPanel & WHM Setup.
- Locate the option that states: “The IP address (only one address) that will be used for setting up shared IP virtual hosts.”
- Change the primary IP address to the new one.
Note: This step may not always be required, but it’s good practice to check and update.
Step 2: Modify Network Configuration via SSH
You need to log in via SSH to make further changes.
- Edit the network interface configuration file:
nano /etc/sysconfig/network-scripts/ifcfg-eth0
- Change the IPADDR and GATEWAY values to match the new server IP address and gateway.
- Edit the main network configuration file:
nano /etc/sysconfig/network
- If the GATEWAY value is missing in the ifcfg-eth0 file, add it here.
Step 3: Update IP in cPanel Configuration Files
- Modify the IPs file:
nano /etc/ips
- Remove the new primary IP if it is already present.
- Add the old primary IP in the format:
OLD_IP:NEW_IP
- Update the cPanel main IP file:
nano /var/cpanel/mainip
- Replace the old primary IP with the new primary IP.
- Modify the hosts file:
nano /etc/hosts
- Replace the old server IP address with the new one if necessary.
- Ensure that the server hostname DNS records are also updated.
Step 4: Restart Services
- Restart the network service to apply the new IP settings:
service network restart
Note: You may get disconnected and need to reconnect using the new IP address.
- Restart the IP aliasing service to ensure additional IPs are brought up:
- service ipaliases restart
- Verify the new IP setup:
ifconfig
- This will list all available IP addresses and confirm that the new one is active.
Step 5: Update cPanel License
- Navigate to the cPanel License Verification page:
- Enter your new primary IP address to check license validity.
- If needed, update the cPanel license to reflect the new IP.
Step 6: Final Verification
- Log in to WHM using the new primary IP.
- Ensure there are no cPanel license warnings or errors.
- Check that all services (websites, email, DNS) are running smoothly.
Conclusion
Changing the primary IP address in cPanel requires careful attention to networking and configuration files. By following the steps outlined above, you can successfully update the server IP address while minimizing downtime and preventing configuration issues. Always ensure backups are in place before making any critical changes to your cPanel server settings.