Change the IP address of a Proxmox host

Change the IP address of a Proxmox host

Proxmox has come a long way since 2008, and the amount that can be configured in the frontend is quite staggering, but sometimes you long for the good old days and want to drop into the terminal. It's just Debian, after all... Hello? Where's everyone gone? Ok, fine, let's start with changing the IP through the web UI:

Changing the IP through the Web UI

There are two changes to make. First, go to System > Network, choose the 'Linux Bridge' interface and click Edit. Enter the new IP here and click OK.

Now click 'Apply Configuration' and the system will reload the network configuration.

Now go to System > Hosts, change the IP address on the line with the hostname and click Save.

Changing the IP with a One-Liner

TL;DR: here's a one-liner:
sed -i 's/oldip/newip/g' /etc/network/interfaces /etc/hosts && systemctl restart networking

The above UI changes are essentially just updating these files:

  • /etc/network/interfaces - This updates the actual NIC/interface address
  • /etc/hosts - If a server hostname is in the hosts file, a system won't perform a DNS lookup for that address. Therefore, host/IP pairings in the hosts file need to be correct.

While you could edit both files manually, change the old IP to the new IP, that's just not as fun as using a one-liner to do it for you! In this example, is the old IP and is the new IP:

# The first command will show you the proposed changes
# without editing any files:

root@prox:~# sed 's/' /etc/network/interfaces /etc/hosts
auto lo
iface lo inet loopback

iface enp3s0 inet manual

auto vmbr0
iface vmbr0 inet static
        bridge-ports enp3s0
        bridge-stp off
        bridge-fd 0

iface wlp2s0 inet manual localhost.localdomain localhost delta.local delta

# The following lines are desirable for IPv6 capable hosts

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


# Adding -i will edit the file in place:

root@prox:~# sed -i 's/' /etc/network/interfaces /etc/hosts
root@prox:~# systemctl restart networking

### One-liner ###

root@prox :~# sed -i 's/' /etc/network/interfaces /etc/hosts && systemctl restart networking
If you're changing more than just the IP address (i.e. you're changing the network/subnet mask/default gateway too), you'll probably want to manually edit both files or edit through the Web UI.

If you can do it with a one-liner, I'm certainly going to try. Hopefully, this helps you, but if you think I've missed something, please leave a comment or let me know over at @techbitsio.

Great! Next, complete checkout for full access to
Welcome back! You've successfully signed in
You've successfully subscribed to
Success! Your account is fully activated, you now have access to all content
Success! Your billing info has been updated
Your billing was not updated