Pi OS 12 Pi 5 - BYO-NTP/recipes GitHub Wiki

date server os
2025 Raspberry Pi 5 Pi OS 12

Install

2. Statically assign your IPv4 address

Unlike the Pi 4 where this doesn't happen, on my Pi 5 running the same Pi OS 12 the MAC address changes with every reboot. This might be due to using an ethernet hat on the Pi 5, which I need with FreeBSD. Since the MAC address changes with every reboot, my DHCP server assigns it a different IP from the pool. Annoying.

It turns out there's at least 3 different syntaxes (in the Debian forums) for how to disable this feature:

  • via /etc/network/interfaces
  • [connection]ethernet.assigned-mac-address=permanent
  • [connection-mac-randomization]cloned-mac-address=permanent

And on May 19th 2025, exactly zero of them work. 😮‍💨

The following hack does work. For now.

Note: this depends on having DNS set up correctly for your hostname. That's a reasonable expectation for a server. Right? Right.

export NTP_IPADDR=$(drill -Q -4 `hostname` || $(ip -4 addr show `ip route get 1.1.1.1 | awk '/ dev / { print $5 }'` | awk '/inet / {print $2}'
	))
export NTP_NETMASK=$(ip -4 addr show `ip route get 1.1.1.1 | awk '/ dev / { print $5 }'` | awk '/inet / {print $2}' | cut -f2 -d/)
export NTP_GATEWAY=$(ip -4 route show default | awk '/default/ {print $3}')

env | grep NTP   # optional, sanity check

nmcli con mod "Wired connection 2" \
    ipv4.address "$NTP_IPADDR/$NTP_NETMASK" \
    ipv4.gateway "$NTP_GATEWAY" \
    ipv4.dns "$(grep ^nameserver /etc/resolv.conf | grep -v : | awk '{ print $2 }' | paste -sd,)" \
    ipv4.method manual
systemctl restart NetworkManager
reboot

References

⚠️ **GitHub.com Fallback** ⚠️