How Do I Exchange the Main and Additional IP Addresses on My Server?

Overview

This guide outlines the process for replacing the main and additional IP addresses for servers. The process for this can differ depending on the operating system (OS) and control panels you are using.

!IMPORTANT! Please note that when planning to exchange IP addresses, DNS-related adjustments should be considered as a priority. As a best practice, we recommend updating DNS records at least 24 hours in advance and reducing the time-to-live (TTL) value to 300 seconds. This approach ensures that, in the event of any issues, the changes can be reverted within five minutes, minimizing potential disruption.

For VPS users, we strongly recommend creating a snapshot before making any network configuration changes. In the event of misconfiguration leading to unreachability, access can be restored via VNC or by reverting to a snapshot. Please note that restoring a snapshot will delete all data written between the time the snapshot was created and the time of the restore. Dedicated server users must request KVM access to resolve such issues.

Please follow the section below relevant to your server’s configuration to find out how to make these changes.

Table of Contents

Windows Server (2016, 2019, 2022) 

To replace the IP addresses on a Windows server, follow the steps below:

  1. Open the Windows Control Panel.
  2. From the Window Control Panel, open “Network and Internet”.
  3. Next open “Network and Sharing Center”.
  4. Select the relevant connection that you want to replace the IPs of. A window that looks like this should open:

  5. Click the “Properties” button.
  6. A new window will open, double click the option “Internet Protocol Version 4 (TCP/IPv4)”
  7. Another window will open where you can edit your main IP address, as well as your subnet mask, the default gateway etc. If you want to edit your additional IPs click the “Advanced” button and follow the steps a, b and c.
    1. A new window will open where you can see a list of your additional IPs. Click the additional IPs you want to replace and then click the “Edit” button. 
    2. A new window will open where you can edit your additional IPs. Once you’re done making your changes, click “OK”.
    3. On the “Advanced TCP/IP settings” window click the “OK” button.
  8. On the “Internet Protocol Version 4 (TCP/IPv4) Properties” window click “OK” to save your changes.
  9. To check the changes open CMD and run the following command:
    ipconfig

Red Hat-based Linux (RHEL, CentOS, AlmaLinux, Rocky Linux) 

To make these changes you will need to edit the interface file. The interface file can be different depending on your own setup, but it is usually located in /etc/sysconfig/network-scripts/ with filenames like ifcfg-eth0.

Once you know where the interface file is located, follow the steps below:

  1. First you will need to edit the main IP config (As mentioned above the interface file can be different so you may need to edit the command depending on where your interface file is setup). To access the main config run the following command:
    sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0  
  2. Once you have access to the main config, you will need to update the following:
    BOOTPROTO=static 
    IPADDR=NEW_MAIN_IP 
    NETMASK=NEW_NETMASK 
    GATEWAY=NEW_GATEWAY 
  3. Next you can add additional IPs (Create alias or secondary config files). To do this run the following command:  
    sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0:1 
  4. You will then need to update the following:
    DEVICE=eth0:1 
    BOOTPROTO=static 
    IPADDR=NEW_ADDITIONAL_IP 
    NETMASK=255.255.255.255 
    ONBOOT=yes
  5. Finally, restart the network service with the following command:
    sudo systemctl restart network 

Debian-based Linux (Debian, classic Ubuntu versions using interfaces) 

To make these changes you will need to edit the interface file. The interface file can be different depending on your own setup, but it is usually located at /etc/network/interfaces.

Once you know where the interface file is located, follow the steps below: 

  1. First you will need to open the configuration file. You can run the following command to open your configuration (As mentioned above the interface file can be different so you may need to edit the command depending on where your interface file is setup.):  
    sudo nano /etc/network/interface
  2. Once you have access to the configuration file you will need to replicate the example below with your own details:
    auto eth0
    iface eth0 inet static
      address NEW_MAIN_IP
      netmask NEW_NETMASK
      gateway NEW_GATEWAY
    
    
    # Additional IP
    iface eth0:0 inet static
      address NEW_ADDITIONAL_IP
      netmask 255.255.255.255 
  3. After you’ve made the changes, restart networking with the command below:
    sudo systemctl restart networking 

Ubuntu (Netplan-based systems) 

To make these changes you will need to edit the interface file. The interface file can be different depending on your own setup, but it is usually located in /etc/netplan/*.yaml.

Once you know where the interface file is located, follow the steps below:

  1. Run the following command to open the interface file. (As mentioned above the interface file can be different so you may need to edit the command depending on where your interface file is setup.):
    sudo nano /etc/netplan/01-netcfg.yaml 
  2. Next, update the file as shown in the example below:
    network: 
      version: 2 
      ethernets: 
        eth0: 
          addresses: 
            - NEW_MAIN_IP/24 
            - NEW_ADDITIONAL_IP/32 
          gateway4: NEW_GATEWAY 
          nameservers: 
            addresses: 
  3. Finally, apply the configuration with the command below:
    sudo netplan apply 
    

Plesk Panel

Follow the steps below to exchange your IP addresses on Plesk:

  1. Login to Plesk as Administrator.
  2. Navigate to Tools & Settings > IP Addresses.
  3. Add the new IP Address.
  4. Remove the old IP address once the services and domains have been migrated.
  5. Update the DNS settings and hosting plans to reflect the new IP.

https://docs.plesk.com/en-US/obsidian/administrator-guide/server-administration/remapping-ip-addresses.80041/

cPanel/WHM 

Follow the steps below to exchange your IP addresses on cPanel/WHM (taken from the official cPanel web-site):

  1. Log into WHM as the ‘root’ user. (IF your cPanel license was already transferred to a new IP and you are getting error about license on your current IP – proceed to step 4)
  2. Navigate to “Home / Server Configuration / Basic WebHost Manager Setup.”
  3. Change the IP address set for “The IP address (only one address) that will be used for setting up shared IP virtual hosts” to the new IP address.
  4. Access the server’s command line as the ‘root’ user via the server’s remote console or out-of-band SSH.
  5. Edit the server’s network configuration to replace the old network configuration with the new network configuration.
    Please note that the specific file or files to be updated depend on the OS the server is running and the network service running on the server. You can find those procedures for each OS type above in this article.
  6. Run the /scripts/mainipcheck script to update the main cPanel IP address.
  7. Run the /scripts/fixetchosts script to update the /etc/hosts file.
  8. Restart the network service.
    Please note that the specific command to restart the network service depends on the OS the server is running and the network service running on the server.
  9. Run the /scripts/build_cpnat script if your server is configured for NAT.
  10. You will likely get disconnected at this time and will need to log in again via the new IP address.
  11. Run the /scripts/restartsrv_ipaliases script if your server has additional IP addresses added through the “Home / IP Functions / Add a New IP Address” interface in WHM.
  12. Run the ifconfig command and verify that the correct information is shown.
  13. Once the new IP is correct in your network configuration, make sure your license is updated to continue using WHM:
    How do I transfer my cPanel/WHM license to another IP address? 
  14. Verify you can log in to WHM.
  15. Review the following article to ensure all other services and websites are brought up to speed on the new IP:
    What to do after the cPanel license IP has changed 

Additional Information

  • Always back up your current configuration before making changes. 
  • For additional IPs, 255.255.255.255 is often used as netmask.
  • Validate changes using ping, ip a, or ifconfig (if installed). 
  • After replacing IPs, test external connectivity and DNS resolution.


Details…

Scroll to Top