How to change the primary IP of a cPanel server is an important task that demands careful planning and execution. Whether you’re moving to a new server, adjusting your network configuration, or replacing an outdated IP, this guide will take you through the process to ensure a seamless transition with minimal disruption.
Step 1: Update Primary IP in WHM
- Log into WHM as the root user.
- Navigate to Home > Server Configuration > Basic WebHost Manager Setup.
- Locate the option: “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.
Step 2: Modify Network Configuration via SSH
- Log in via SSH to your server as the root user.
- 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.
- If the GATEWAY value is missing in the ifcfg-eth0 file, add it in the main network configuration file:
nano /etc/sysconfig/network
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. Also ensure that the server hostname DNS records are also updated.
Step 4: Restart Network Service
- 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.
- 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
- Go to the cPanel License Verification page.
- Enter your new primary IP address to verify the license status.
- If necessary, update your cPanel license to match the new IP address.
Step 6: Final Verification
Log in to WHM using the new primary IP address and make sure that there are no cPanel license warnings or errors. If you’re running websites on your current main IP, all these websites will need to use the new IP after you change it.
Conclusion
Changing the primary IP address in cPanel requires careful handling of network and configuration files. By following the steps outlined in this guide on how to change the primary IP of a cPanel, you can update the server IP with minimal downtime and avoid issues. Always ensure backups are taken before making any major changes.