Normally in all servers, the outbound connections from a server will be originating from the primary IP of the server. This is the case in a cPanel server as well. So if an IP is blacklisted, or blocked, some where we may need to change the primary IP address of the server. If we are changing the network range this is needed.
I’d suggest to disable any firewall in the server before we start.
Step1. Login to the server via SSH , and open the file /etc/sysconfig/network-scripts/ifcfg-eth0, Change the IPADDR and GATEWAY entries to match the new IP and Gateway.
Step2. Then edit the file at /etc/sysconfig/network , if the GATEWAY entry is there, change it.
This much is needed in a normal CentOS server. You can now restart the network service and have the new IP in the server. If you have cPanel installed, Please proceed further. cPanel have a few hardcoded locations where it save the IP address information, and they are…
- /var/cpanel/mainip. Replace the old IP with the new one in this file.
- /etc/ips . This file should not contain The main IP.
- /etc/hosts. Replace the old IP with the new one in this file.
Restart network and ipaliases service
service network restart service ipaliases restart
Note: You're probably going to be disconnected at this point, and have to log in to ssh using the new primary ip, and restart the ipaliases service. Once you are up in the new IP, make sure that you have the cPanel license installed for the new IP and you might need to update the license using the command /usr/local/cpanel/cpkeyclt
You will then need to login to WHM, and update the new IP in cPanel -> Basic Server settings, if you have the old IP listed there.
Again, if you are having a lot of websites running on that old IP you will need to change their IP from WHM -> Change Site’s IP address.
You will then need to update all your monitoring system to use the new IP – or else you’ll get those false alarms every now and then.