Hi everyone, I'm still learning how to use Proxmox fully and I wanted to ask you if there was a way to set up DHCP on Proxmox so that if I move to another network the machine can still connect and I can connect to it.
/etc/network/interfaces
/etc/hosts
auto vmbr0
iface vmbr0 inet static
address 192.168.17.15/23
...
/etc/network/interfaces
toauto vmbr0
iface vmbr0 inet dhcp
/etc/hosts
manually, as PVE expects this to match its actual IP.thx so much for the helpHey,
I assume you mean that the PVE host uses DHCP instead of a statically configured IP, not setting up a DHCP server on the host.
It is recommended to stick with a static IP for the PVE host, for standalone hosts changing the IP is somewhat straight forward, you basically have to update both
-/etc/network/interfaces
- and/etc/hosts
In a cluster this is more involved.
If you still decide to go with DHCP you can change
inCode:auto vmbr0 iface vmbr0 inet static address 192.168.17.15/23 ...
/etc/network/interfaces
to
But keep in mind you still have to updateCode:auto vmbr0 iface vmbr0 inet dhcp
/etc/hosts
manually, as PVE expects this to match its actual IP.
/etc/dhcp/dhclient-exit-hooks.d/
:# /etc/dhcp/dhclient-exit-hooks.d/update-etc-hosts
if ([ $reason = "BOUND" ] || [ $reason = "RENEW" ])
then
sed -i "s/^.*\spve.example.com\s.*$/${new_ip_address} pve.example.com pve/" /etc/hosts
fi
pve.example.com
with your actual Proxmox node hostname. You can verify it using:hostname -A
/etc/hosts
file stays in sync with your DHCP-assigned IP.question and what if I wanted to change the IP with one of another class instead?Hey,
I assume you mean that the PVE host uses DHCP instead of a statically configured IP, not setting up a DHCP server on the host.
It is recommended to stick with a static IP for the PVE host, for standalone hosts changing the IP is somewhat straight forward, you basically have to update both
-/etc/network/interfaces
- and/etc/hosts
In a cluster this is more involved.
If you still decide to go with DHCP you can change
inCode:auto vmbr0 iface vmbr0 inet static address 192.168.17.15/23 ...
/etc/network/interfaces
to
But keep in mind you still have to updateCode:auto vmbr0 iface vmbr0 inet dhcp
/etc/hosts
manually, as PVE expects this to match its actual IP.
ahhhh understand thanks for the help guysTo expand on Hannes’s point: Proxmox VE relies on its current IP being accurately reflected in /etc/hosts. Manually updating this file each time the IP changes can be tedious and error-prone, especially if you're relying on remote access.
If you're using DHCP and want to automate this step, you can add a DHCP client hook at/etc/dhcp/dhclient-exit-hooks.d/
:
Be sure to replaceBash:# /etc/dhcp/dhclient-exit-hooks.d/update-etc-hosts if ([ $reason = "BOUND" ] || [ $reason = "RENEW" ]) then sed -i "s/^.*\spve.example.com\s.*$/${new_ip_address} pve.example.com pve/" /etc/hosts fi
pve.example.com
with your actual Proxmox node hostname. You can verify it using:
This ensures yourBash:hostname -A
/etc/hosts
file stays in sync with your DHCP-assigned IP.
there is no difference between changing the IP or the subnet, both are part of the address, it doesn't matter which part of the address is changed.question and what if I wanted to change the IP with one of another class instead?
thx for the helpthere is no difference between changing the IP or the subnet, both are part of the address, it doesn't matter which part of the address is changed.
We use essential cookies to make this site work, and optional cookies to enhance your experience.