How to change the private IP of a server

coursevector

Well-Known Member
Feb 23, 2015
161
20
68
cPanel Access Level
Root Administrator
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
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,298
1,279
313
Houston
Hello,


We've been asked for something like this a couple of times and I've opened a case to have a tutorial/guide created for users. Right now though, we don't have a guide or a best practice for this specific circumstance.

You might want to check out the following though:


Specifically the manage IP addresses section. It seems that there may have been an issue in your case when you ran the IP migration wizard though and I wonder if the documentation on that might help clarify?

 

coursevector

Well-Known Member
Feb 23, 2015
161
20
68
cPanel Access Level
Root Administrator
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!
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,298
1,279
313
Houston
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.
 

IndicHosts.net

Well-Known Member
Mar 11, 2006
74
28
168
Online
cPanel Access Level
Root Administrator
Incase you are still wondering, here's what we follow
  1. After restoring snapshot, assign static IPv4 to new VM
  2. WHM > Basic WHM Setup - Update the new static IPv4
  3. WHM > Basic WHM Setup - Update the new IPv6 (or remove /leave blank)
  4. WHM > IP Migration Wizard - Update NAT's Private IPv4 from one in snapshot to new Private IPv4 of VM
  5. In case you use external DNS (R53, Domain Registrar, CF or else) update the DNS A records with new IPv4 / IPv6
Give it a few minutes and your up.
 

RNTRICE

Registered
May 1, 2022
1
0
0
USA
cPanel Access Level
Website Owner
Incase you are still wondering, here's what we follow
  1. After restoring snapshot, assign static IPv4 to new VM
  2. WHM > Basic WHM Setup - Update the new static IPv4
  3. WHM > Basic WHM Setup - Update the new IPv6 (or remove /leave blank)
  4. WHM > IP Migration Wizard - Update NAT's Private IPv4 from one in snapshot to new Private IPv4 of VM
  5. In case you use external DNS (R53, Domain Registrar, CF or else) update the DNS A records with new IPv4 / IPv6
Give it a few minutes and your up.
Damn, Thanks, man! I was in a bad place until I came across your post!