If you are using a cPanel/WHM interface to manage the web hosting, some changes are needed to be done if the main IP address of the server got changed due to some reason. Here I am providing the steps to be done at the WHM panel after an IP change is done at the server-side. You can watch the video tutorial by clicking on this link.
- The WHM will be accessible with the new IP address using port 2087 if there is no specific firewall restriction is applied on the server to block the new IP.
- Once logged in, the first thing to be changed is the 'shared IPv4 virtual hosts' option from the Home »Server Configuration »Basic WebHost Manager Setup.
- Then you can manage the added IP addresses via Home »IP Functions »Show or Delete Current IP Addresses. You can remove the old IPs from here and also add if you have more IPs using the Home »IP Functions »Add a New IP Address option.
These are the major changes to be done inside the WHM panel. But we also have to make a few changes via the command line as well.
1. Change the main IP in /var/cpanel/mainip, replacing the old with the new IP.
2. Then you need to fix the entries in the '/etc/hosts' file. Either you can do it manually or using the cPanel script '/scripts/fixetchosts'.
3. Next, we need to restart the network service and rebuild NAT with the build_cpnat script for those 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
Please note you will likely get disconnected from the server at this time and will need to log in again with the new IP.
4. If you had additional IPs, restart the 'ipaliases' script to bring up the additional IPs to the interface using the 'service ipaliases restart' command.
5. Make sure that all configuration is good using the 'ifconfig' command and also remember to change the license IP to the new one as well.