PDA

View Full Version : How to restore WHM after IP change



Fli
11-30-2014, 07:59 PM
How do You restore your WHM/cPanel server to work on new IP / VPS IP?

I composed this tutorial and i am updating it.

CASE 1
In case you can assign new IP while old IP is still assigned (old and new IP provider is the same), then i would do WHM > IP functions > IP Migration Wizard which should guide one thru the process.

CASE 2
But in case your old server died/you transfered data to other server, then i did following steps on new server.

1) Go to website where i bought cpanel license and change license IP
2) run linux command: /usr/local/cpanel/cpkeyclt (update cpanel license so it works on new VPS IP)
3) WHM > IP functions > IP Migration Wizard
4) WHM >> Multi Account Functions >> Change multiple sites' IP address (this process also changes all DNS zones IPs from odl to new)
4) Server Configuration > Basic cPanel & WHM Setup , change IP address from old to new and then on the bottom "Assign IP address" to the nameservers
5) WHM >> Restart Services >> DNS Server (BIND/NSD/MyDNS) - this step may not be necessary
6) update your nameservers IP (in domain registar panel, example godaddy.com)
7) setup iptables rules/s to redirect old IP traffic to the new IP:
a) iptables -t nat -I PREROUTING -p tcp -d OLD_IP_HERE --dport PORT_HERE -j DNAT --to NEW_IP_HERE
(not sure if PORT_HERE have to be only 80, if not necessary to create second rule for port 53 etc)
b) https://www.debuntu.org/how-to-redirecting-network-traffic-to-a-new-ip-using-iptables/?replytocom=142049#respond
c) port forwarding? http://www.revsys.com/writings/quicktips/ssh-tunnel.html
8) If using dot.tk domain registar and having domains there, login and at page "Default name servers (http://my.domainshare.tk/)", set new IP and select option "I do want to update all my domains in my portfolio that were configured with my previous default name server values."
9) if some domains hosted on the WHM server are using Cloudflare that was not setup from within cpanel, then owners need to manually update IP in their Cloudflare account, DNS section. To learn which domains using Cloudflare, run command: grep -Rl "cloudflare.com" /var/named/cache/
Or you can run following command to discover domains+usernames+their e-mails:

for domain in $(grep -Rl "cloudflare.com" /var/named/cache/|sed s'|/var/named/cache/||'g|sed s'|.db||'g);do userfile=$(grep -Rl $domain /var/cpanel/users);useremail=$(cat $userfile|grep "@"|sed s'/CONTACTEMAIL=//'g) && echo "$useremail $domain $userfile";done
ps: when turning on/off CF on some site, make sure your php scripts do not expect CF. Example ZBBlock script in its /vault/zbblock.ini needs changing ip_origin variable.
11) if you use some kind of reverse proxy in front of your server or you have set some uptime monitors or remote scripts (backup scripts) that can hold old server IP, update them
10) this step apply only on my case as i have "hardcoded" WHM IP inside virtualhost file: Service Configuration/Apache Configuration/Include Editor/Pre VirtualHost Include . Replace old IP by new.

-----
Post Your feedback and experience here