1 03 Hostnames and DNS Registration on bootc
Eric the IT Guy edited this page 2026-08-12 12:49:28 -05:00

Part 3: Hostnames and DNS Registration on bootc

This one nearly broke me, because one bootc host registered in DNS perfectly and an identical-looking one refused to, and I was sure they were the same. They were not.

The symptom

itg-dev-bootc was reachable by name from other boxes. itg-prd-forge was not, even though both were built from the same base and both pulled DHCP leases fine. From another host, getent hosts itg-prd-forge came back empty, and worse, the forge box's own hostname had somehow become git.itguyeric.com.

Two kinds of hostname, and only one gets advertised

The difference was how each host set its hostname.

  • A static hostname (hostnamectl set-hostname, which writes /etc/hostname) is what NetworkManager advertises to DHCP. OPNsense's Unbound watches DHCP leases and auto-registers that name in DNS. This is the one that works.
  • A transient hostname set by a kernel argument (systemd.hostname= via a 20-hostname.toml karg) is NOT advertised to DHCP. The host knows its own name, but nothing else ever hears about it. That was the forge box.

So the fix for registration is to set a real static hostname. I bake it as a oneshot that runs before NetworkManager on first boot only:

[Unit]
Description=Set static hostname
After=systemd-hostnamed.service
Before=NetworkManager.service
ConditionPathExists=!/etc/hostname
[Service]
Type=oneshot
ExecStart=/usr/bin/hostnamectl set-hostname itg-prd-forge

The ConditionPathExists=!/etc/hostname means it only sets the name if one is not already set, so it does not stomp anything on later boots.

The reverse-DNS clobber

The other half of the mystery: why did forge rename itself to git.itguyeric.com? NetworkManager, by default, does a reverse-DNS lookup on the IP it gets and adopts whatever name comes back. That IP happened to have a git override in Unbound, so NM helpfully renamed the box to it. The fix, baked into itg-base for the whole fleet:

[main]
hostname-mode=none

That drop-in tells NetworkManager to stop touching the hostname at all, so my static name sticks and NM never reverse-DNSes over it.

Lessons

  • Static hostname (/etc/hostname via hostnamectl) is the one DHCP advertises and Unbound registers. A kernel-arg hostname is invisible to the network.
  • hostname-mode=none in NetworkManager stops the reverse-DNS rename that silently gives your host the wrong name.
  • When two "identical" bootc hosts behave differently, check how each one actually sets its hostname before assuming they match.