TL;DR Set up your sole node Proxmox VE install as any other server - with DHCP assigned IP address. Useful when IPs are managed as static reservations or dynamic environments. No pesky scripting involved.
ORIGINAL POST DHCP setup of a single node
This is a specialised case. It does NOT require DHCP static reservations and does NOT rely on DNS resolution. It is therefore easily feasible in a typical homelab setup.
CAUTION This setup is NOT meant for clustered nodes. Refer to a separate guide on setting up entire cluster with DHCP if you are looking to do so.
- ISO Installer ^ - set interim static IP, desired hostname (e.g. pvehost); or
- Debian-based install. ^
This is a plug-in module ^ for Name Service Switch (NSS) that will help you resolve your own hostname correctly.
apt install -y libnss-myhostname
NOTE
This will modify your /etc/nsswitch.conf
^ file automatically.
Remove superfluous static hostname entry in the /etc/hosts
file, ^ e.g. remove 10.10.10.10 pvehost.internal pvehost
line completely. The result will look like this:
127.0.0.1 localhost.localdomain localhost # 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
CAUTION On regular Debian install, the line to remove is one starting with127.0.1.1
line. This is NOT to be confused with127.0.0.1
that shall remain intact.
On a fresh install, this is the second line and can be swiftly removed - also creates a backup of the original:
sed -i.bak '2d' /etc/hosts
PVE will take the first of the IPs resolved as its default. This can be verified with:
hostname -i
fe80::5054:ff:fece:8594%vmbr0 10.10.10.10
It is more than likely, that your first (left-most) IP is an IPv6 and (unless you have a full IPv6 setup) a link-local one at that - not what you want.
To prefer IPv4, you can modify the default behaviour by adding this specific configuration to /etc/gai.conf
file ^ - we will make a backup first:
cp /etc/gai.conf{,.bak} cat >> /etc/gai.conf <<< "precedence ::ffff:0:0/96 100"
Now hostname -i
will yield:
10.10.10.10 fe80::5054:ff:fece:8594%vmbr0
If you have a very basic setup with single IPv4 this will be enough. If you, however, have multiple IPs on multiple interfaces, you might end up with output like this:
192.168.0.10 10.10.10.10 fe80::5054:ff:fe09:a200%enp2s0 fe80::5054:ff:fece:8594%vmbr0
You will need to further tweak which one will get ordered as first by adding, e.g.:
cat >> /etc/gai.conf <<< "scopev4 ::ffff:10.10.10.0/120 1"
This is your preferred IPv4 subnet left-padded with ::ffff:
and number of IPv4 subnet mask bits added up to 96, hence this will prefer 10.10.10.0/24 addresses. The check will now yield:
10.10.10.10 192.168.0.10 fe80::5054:ff:fe09:a200%enp2s0 fe80::5054:ff:fece:8594%vmbr0
On a standard ISO install, change /etc/network/interfaces
^ bridge entry from static
to dhcp
and remove statically specified address
and gateway
:
auto lo iface lo inet loopback iface enp1s0 inet manual auto vmbr0 iface vmbr0 inet dhcp bridge-ports enp1s0 bridge-stp off bridge-fd 0
CAUTION Debian requires you to set up your own networking for the bridge - if you want the same outcome as Proxmox install would default to ^ - as Debian instead defaults to DHCP on the regular interface with no bridging.
Either perform full reboot, or at the least restart networking and pve-cluster service:
systemctl restart networking systemctl restart pve-cluster
You can check addresses on your interfaces with:
ip -c a
Afterwards, you may wish to check if everything is alright with PVE:
journalctl -eu pve-cluster
It should contain a line such as (with NO errors):
pvehost pmxcfs[706]: [main] notice: resolved node name 'pvehost' to '10.10.10.10' for default node IP address
And that’s about it. You can now move your single node around without experiencing strange woes such as inexplicable SSL key errors due to unmounted filesystem due to a petty configuration item.