How to Safely Change the Primary Proxmox VE IP Address

While operating your virtual environment with Proxmox VE, you may need to change the IP address of a Proxmox host. The reasons can differ – you might want to restructure a local datacenter, reallocate the office, or migrate a host to another datacenter provider. Read this step-by-step guide on how to change a Proxmox IP address.

NAKIVO for Proxmox Backup

NAKIVO for Proxmox Backup

Agentless, app-aware backup for Proxmox VE with multiple targets, including immutable cloud backups. Multiple instant granular recovery and full recovery options.

Prerequisites for Changing the Proxmox VE IP Address

When installing Proxmox, the installer asks you to define the static IP address configuration. Obtaining IP configuration via DHCP is also possible (for example, you can bind a leased IP address to a MAC address of a network card of a Proxmox host via DHCP), but static IP configuration is recommended.

When we mention a primary Proxmox IP address, we usually mean the IP address used for managing the Proxmox host. Other IP addresses can exist on other physical network adapters to connect shared storage, for example, or on the Proxmox host used for routed VM networks (NAT networks). The main purpose of this blog is to change the Proxmox IP address used for host management.

In this post, the initial configuration of a Proxmox host is as follows:

  • IP address: 192.168.101.229 (the Proxmox static IP address)
  • Network mask: 255.255.255.0
  • Gateway: 192.168.101.2
  • Hostname: deb-proxmox
  • A network bridge is configured for 192.168.101.229 to establish a connection between virtual machines and the physical network and between each other.
  • A Proxmox host (192.168.101.229) is not a cluster member. The workflow for a cluster is different.

The main and most efficient method to change the Proxmox IP address is by using the command line. Alternatively, the Proxmox web interface can be used. Read this blog post about how to install Proxmox to learn more about the installation and initial configuration.

Changing the Proxmox IP Address in the Command Line

Connect to a Proxmox host via SSH and log in to the host. To access the Proxmox command line, you can use an SSH client or click the Shell button for a selected host in the Proxmox web interface. Ensure that an SSH server is configured on the Proxmox host and the firewall is not blocking the connection if you use an SSH client.

  1. You need the root privileges to change the system configuration, including the IP configuration. To get the root privileges, use the command:

    sudo -i

  2. Check the current IP configuration of a Proxmox host:

    ifconfig

    In the output, we can see the bridged vmbr0 interface that we need to configure (vmbr0 is bridged to ens33). Be aware that the name of your interface and the IP address can be different. In this example, vmbr1 (10.10.101.229) connected to ens36 is the interface for the VM NAT network. We will not make any changes to the 10.10.101.0/24 network used for VMs behind the NAT (behind a router on Proxmox).

    Checking the current Proxmox IP address

    NOTE: The recommended practice is to back up a configuration file before making changes. You can create a copy of the file using the cp command, such as cp file-original file-copy

  3. Change the IP address by editing the /etc/network/interfaces file in a text editor. You can use the lightweight built-in nano or the advanced text editor vim.

    nano /etc/network/interfaces

    • If you set a new IP address from another network, you need to change the gateway IP address in the Proxmox IP network configuration.
    • You may need to change a DNS nameserver IP address. Different DNS servers can be used for different networks.

      NOTE 1: If you have a routed network (NAT network) for VMs, you may want to change the corresponding IP addresses, networks, and gateways as well. In this case, edit the IP addresses of the appropriate interfaces, networks, and iptables rules for routing.

      NOTE 2: If you connect your host to another network, for example, /16 instead of /24 (with network mask 255.255.0.0 instead of 255.255.255.0), adjust the network address and mask accordingly in the IP network configuration.

      In this example, we change 192.168.101.229 to 192.168.105.229 as the IP address for the bridged network interface and Proxmox host management (we don’t edit the configuration of the NAT network).

      We change the gateway 192.168.101.2 to 192.168.105.2 to make it correct for the corresponding network 192.168.105.0/24.

    • Press Ctrl+O to save the changes in the file and press Ctrl+X to exit nano.

    How to change Proxmox IP address in the command line

  4. Edit the /etc/hosts file to edit the hostname because the hostname must match the new IP address to resolve it correctly.

    nano /etc/hosts

    In this example, we change 192.168.101.229 to 192.168.105.229 for deb-proxmox. Your values can be different – edit the corresponding values in your configuration.

    Once you have edited the needed values, press Ctrl+O to write the changes to the file and press Ctrl+X to exit nano, the text editor.

    Editing the Proxmox IP address in the host file for the correct DNS lookup

  5. Restart the networking service to make the changes take effect.

    systemctl restart networking

If you cannot restart the networking service or restarting networking doesn’t help, then reboot the host with the init 6 command. Ensure that virtual machines are powered off before doing this.

Note that after changing the Proxmox IP address and restarting the networking service, you need to use the new IP address when connecting to the Proxmox host via the web interface or SSH. You should reconnect to the Proxmox host in this case. Ensure that you are connected to the correct network.

Changing the Proxmox IP Address in the Web Interface

The second method to change a Proxmox IP address is using the graphical user interface, which is the Proxmox web user interface. This method can be preferred by new users, but the configuration principle remains the same – you edit the IP configuration by making changes to the /etc/network/interfaces file and then edit the hostname by making changes to /etc/hosts. These settings are performed in the Proxmox management web interface for more convenience.

The initial configuration of a Proxmox host in this example is the same as at the beginning of the configuration by using the previous method (when we used the command line). The Proxmox web UI can be accessed with the https://192.168.101.229:8006 link in our case. 8006 is the Proxmox default port for the web interface.

  1. Log in to the web interface of Proxmox VE and, in the navigation pane, select the host which IP address you want to change. In this example, we select the host called deb-proxmox.
  2. Go to System > Network. Select the network interface used for Proxmox host management (whose IP address you want to change) and click Edit. We select vmbr0 as the network interface.

    Editing the network interface

  3. A configuration window for the selected network interface opens:
    • IPv4/CIDR: Enter the new IP address and network mask (CIDR).
    • Gateway: Enter the new gateway if you have changed the IP address to the IP address from another network.
    • You can leave other settings as is.

    We change 192.168.101.229/24 to 192.168.105.229/24 and 192.168.101.2 to 192.168.105.2. As you can see in the screenshot below, the bridged interface vmbr0 is linked to the ens33 network adapter (interface).

    Click OK to save Proxmox IP address settings and close the current window.

    How to change Proxmox IP address in the web interface

  4. Go to System > Hosts. You can see the contents of the /etc/hosts file displayed in a special field of the web interface where you can directly edit the contents of the hosts file.

    Change the old IP address to the new IP address in the host’s configuration for the correct hostname resolution and click Save. We change 192.168.101.229 to 192.168.105.229 for deb-proxmox.

    Editing the host file in the Proxmox web interface

  5. Now, go back to System > Network, where you selected the network interface to change the Proxmox IP address. Click Apply Configuration to apply the network changes made before.

    Do you want to apply pending network changes? Hit Yes. The networking service will restart.

    Applying network changes

  6. Wait until the networking service is restarted.
  7. Connect the host to another physical network if needed.
  8. Enter the new IP address of the Proxmox host to log in to a user interface. Ensure you are connected to the correct network with access to the Proxmox host with the new IP address. In our case, the new link to the Proxmox web UI is https://192.168.101.229:8006 where 8006 is the Proxmox default port.

Changing the IP Address in a Proxmox Cluster

If you have a Proxmox cluster, using the approach explained above cannot be used because issues can occur despite the fact that some actions are common in both cases. The process for changing the IP address in a Proxmox cluster includes updating the network configuration, modifying the cluster configuration, and adjusting the corosync configuration.

Below, we show a basic workflow, which may differ in your environment depending on several factors, such as using an Open vSwitch, VLAN configuration, the number of cluster nodes with changed IP addresses, and other configuration parameters.

It is recommended that you change the IP address of one cluster node (a Proxmox host which is a cluster member) at time. This approach allows you to ensure that a cluster remains in an operational state.

  1. To avoid disruptions, stop the cluster-related services on the node whose IP address is being changed:

    systemctl stop pve-cluster

    systemctl stop corosync

  2. Edit the network configuration to reflect the new IP address for the Proxmox host:

    nano /etc/network/interfaces

    Modify the relevant network interface to use the new IP address. For example:

    iface vmbr0 inet static

    address <new-ip-address>

    netmask 255.255.255.0

    gateway <gateway-ip>

    bridge_ports eth0

    bridge_stp off

    bridge_fd 0

    Save the file and restart the network service on the host:

    systemctl restart networking

  3. Update the /etc/hosts file with the new IP address:

    nano /etc/hosts

    Replace the old IP address with the new one for the corresponding hostname.

  4. Modify the Proxmox cluster configuration to reflect the new IP address:

    nano /etc/pve/corosync.conf

    Locate the section for the node whose IP address is being changed and update the IP address:

    node {

    name: <node-name>

    nodeid: <node-id>

    quorum_votes: 1

    ring0_addr: <new-ip-address>

    }

    Save the file.

  5. Update Corosync configuration. If using a version of Proxmox that uses Corosync 3.x, you may need to adjust the Corosync transport and bindnetaddr settings:

    nano /etc/pve/corosync.conf

    Ensure the bindnetaddr reflects the network address associated with the new IP configuration:

     totem {

    ...

    interface {

    ringnumber: 0

    bindnetaddr: <network-address>

    mcastport: 5405

    ttl: 1

    }

    ...

    }

    The corosync service is used to synchronize the cluster configuration among all cluster nodes. It is enough to edit corosync configuration on one node and then the changed configuration is synchronized with other nodes in the cluster.

  6. Restart the cluster-related services on the target node:

    systemctl start corosync

    systemctl start pve-cluster

  7. If you have any firewall rules or other configurations tied to the old IP address, update them accordingly.
  8. Ensure the node is reachable with the new IP address and is functioning correctly within the cluster:

    ping <new-ip-address>

    pvecm status

  9. When all the steps are done and services restarted, the cluster should operate with the node whose IP configuration was updated. If you need to change the IP address of the second node, repeat the steps for the second node of the Proxmox cluster.
  10. Once the configuration on all nodes has been updated, update the known_hosts file with the new IP addresses on all Proxmox nodes. This way, you ensure that the nodes can reach each other seamlessly:

    /etc/pve/priv/known_hosts

    You can try to connect from each node to all other nodes via SSH.

Conclusion

Changing a main Proxmox IP address on a non-cluster server can be done in the command line interface and Proxmox web interface. Both methods require editing /etc/network/interfaces and /etc/hosts configuration files and changing the IP address in these files. The difference between these methods is how you access these files. If a Proxmox host is a cluster node, the workflow is different. Do not use the workflow to change the IP address in a non-clustered host if a host is a cluster member. It is recommended that you back up the original configuration before making changes.

Try NAKIVO Backup & Replication

Try NAKIVO Backup & Replication

Get a free trial to explore all the solution’s data protection capabilities. 15 days for free. Zero feature or capacity limitations. No credit card required.

People also read