SiteHost

Swapping IP addresses between servers

Updating infrastructure software is required to ensure applications are safe and stable. When it comes to upgrading a Virtual Server Operating System, our recommended approach is to deploy a new server and move your applications over to the new gear.

For most cases, switching over to the new server updating DNS records is simpler and involves less downtime, but we understand there are edge cases where reusing the IP address assigned to your production gear means less downtime.

In this article, we explain how you can reuse the IP address already assigned to your "old server". We would recommend you read the entire article before starting with your migration procedure.

Step 1 - Deploy a new server

What's important to mention here is that an IP address can't easily be moved to a different region. In saying this, please ensure you deploy your "new server" on the same region your "old server" has been deployed.

Test your new server works as expected and move on to the next step when you are ready to switch the new server to production.

Step 2 - Backup the network configurations

It's important to have a plan B, so backup the network configuration of both Virtual Servers before proceeding. You can either copy the configuration to a text file in your local workstation or take a screenshot of the network configuration shown in the SiteHost Control Panel - search for the Network Config button at the server's management page.

Step 3 - Snapshot both servers

Another important step in case you need to go for the plan B: Take snapshots of both servers through the SiteHost Control Panel. See the Snapshots article for more information on this.

Step 4 - Deallocate IP addresses

You need to deallocate the IP address that is important for you to keep before you can re-allocate it to the new server. Using the SiteHost Control Panel, follow the steps:

  1. Browse to Servers in the left menu
  2. Select your old server from the list
  3. Click the delete icon at the IPv4 Addresses and IPv6 Addresses sections to remove the allocated IP addresses
  4. Browse to Servers in the left menu again
  5. Select the new server from the list
  6. Click the delete icon at the IPv4 Addresses and IPv6 Addresses sections to remove the allocated IP addresses

Step 5 - Re-allocate IP addresses

It's time to swap the IP addresses:

  1. When in the new server's management page, hit the Manage IP Addresses button
  2. At the Add New IP Address section, use the drop-down menu to select the important IP address

For convenience, let's assign the other IP address to the old server so you can access it if needed.

  1. Browse to Servers in the left menu
  2. Select your old server from the list
  3. Hit the Manage IP Addresses button
  4. At the Add New IP Address section, use the drop-down menu to select the other IP address.

Step 6 - Change Network Configuration on the Virtual Servers

For both servers follow the steps:

  1. Put the server into Rescue Mode
  2. Log in to the new server's Rescue Environment and follow the instructions to mount the server's root partition at the /mnt mount point
  3. Copy the network configuration from the Rescue Operating System into correct file paths in /mnt. The SiteHost Control Panel will indicate the file paths, hit the Network Config button at the server's management page to double-check
  4. Remove the server from the Rescue Mode so it boots up using the recently assigned IP address
  5. Test as convenient: If you log in via SSH you should get a warning that the fingerprint has changed, that's expected

The Plan B - Rolling back the changes

If something went wrong and you can't figure out what is it, you can roll back the changes made to the server's Operating System by restoring the snapshots. This won't revert the changes regarding the IP addresses allocation though, so you need to revert these using the SiteHost Control Panel before restoring the snapshots.

We would suggest reviewing the steps 4 and 5 and double-check the network configuration files backed up to ensure you have IP addresses allocated matching the server's Operating System configuration.