How to change the private IP of a server
What is the proper way to update a server once the public and private IP have been changed? This is a common scenario when restoring a snapshot (or upgrading an instance) on AWS Lightsail. The snapshot restores to a new instance where a new public IP AND private IP are given to the system. A static IP can be migrated over to the new instance, but that still leaves the new private IP in a NAT configuration needing to be updated.
My current steps I've learned from trial and error consist of:
1. Changing the public IP in "Basic WHM Setup" to the correct public IP
2. Running /scripts/build_cpnat
3. Running /scripts/rebuildhttpdconf
4. Running /scripts/restartsrv_apache
5. Then going to "Manage AutoSSL" and running "Run AutoSSL For All Users"
But even then, i'm not always successful in getting it to load the sites properly. Last night I did those steps, even tried the IP Migration Wizard and got into an even weirder situation. Where on the Accounts List page, it showed the right IP. But on the IP Migration Wizard it showed the old private IP. And if I tried to change an individual account's IP it said it was already changed to the new public IP. Eventually I ran through as many internal DNS/IP files I could find ( /var/cpanel/cpnat, /etc/hosts, /etc/ips.dnsmaster, /var/cpanel/mainip, /etc/userdatadomains ) to verify it was correct and updated. I tried /scripts/rebuildippool, /scripts/cleandns, and /scripts/fixvaliases with no luck. Eventually running /usr/local/cpanel/scripts/updateuserdomains fixed the IP Migration Wizard screen. And yet, the sites still wouldn't load.
So here I am, asking what is the recommended procedure to get a cPanel server running CentOS 7, to change it's private and public IP addresses and get the sites running as quickly as possible. Thanks
-
The documentation didn't help too much. I had to make another attempt. I did the same steps i listed before: 1. Changing the public IP in "Basic WHM Setup" to the correct public IP 2. Running /scripts/build_cpnat 3. Running /scripts/rebuildhttpdconf 4. Running /scripts/restartsrv_apache But this time did: 5. /usr/local/cpanel/scripts/updateuserdomains 6. /scripts/rebuildippool 7. IP Migration Wizard and up until step 7, nothing worked. But running through the migration wizard seemed to fix it for me this time. At this point i consider it black magic and just throw spaghetti at the wall until something works. =( Looking forward to a definitive guide on this! 0 -
I'm so happy it worked this time! At this point i consider it black magic and just throw spaghetti at the wall until something works.
I'm sorry, but I can't stop laughing at this.Looking forward to a definitive guide on this!
This might not happen for a little bit but I will most certainly update here when we get something written up.0 -
Incase you are still wondering, here's what we follow - After restoring snapshot, assign static IPv4 to new VM
- WHM > Basic WHM Setup - Update the new static IPv4
- WHM > Basic WHM Setup - Update the new IPv6 (or remove /leave blank)
- WHM > IP Migration Wizard - Update NAT's Private IPv4 from one in snapshot to new Private IPv4 of VM
- In case you use external DNS (R53, Domain Registrar, CF or else) update the DNS A records with new IPv4 / IPv6
0 -
Thanks for sharing your solution! 0 -
Incase you are still wondering, here's what we follow
- After restoring snapshot, assign static IPv4 to new VM
- WHM > Basic WHM Setup - Update the new static IPv4
- WHM > Basic WHM Setup - Update the new IPv6 (or remove /leave blank)
- WHM > IP Migration Wizard - Update NAT's Private IPv4 from one in snapshot to new Private IPv4 of VM
- In case you use external DNS (R53, Domain Registrar, CF or else) update the DNS A records with new IPv4 / IPv6
Damn, Thanks, man! I was in a bad place until I came across your post!0
Please sign in to leave a comment.
Comments
6 comments