Concur. Before freedesktop and systemd complicated the process it was simply a matter of running hostname <host_name_you_want> as root and then echo host_name_you_want > /etc/hostname (also as root). Then modify /etc/hosts to append the domain_you_want to the local hostname completing name lookup (and making the C and shell commands for hostname and dnsdomainname happy). The traditional syntax for /etc/hosts is (with comments included) is:#3 and add the host name to /etc/hostname. Although I'm not sure that I've ever seen a Pi OS not set that.
Code:
## hosts This file describes a number of hostname-to-address# mappings for the TCP/IP subsystem. It is mostly# used at boot time, when no name servers are running.# On small systems, this file can be used instead of a# "named" name server.# Syntax:## IP-Address Full-Qualified-Hostname Short-Hostname## Raspberry Pi specific 127.0.1.1 used in addition to localhost (at least through bullseye)127.0.1.1 rpzero.mydomain.com rpzero# local host and loopback127.0.0.1 localhost::1 localhost ip6-localhost ip6-loopbackff02::1 ip6-allnodesff02::2 ip6-allroutersThe systemd resolver management of /etc/resolv.conf can either be your friend or you enemy depending on how name-resolution is handled on your network. As others have mentioned, resolv.conf should contain "search mydomain.com" continuing from the example above, and "nameserver xxx.xxx.xxx.xxx" with the IP of any DNS server (and backup) you use to resolve addresses. This can take information passed to it from your dhcp server or what the systemd-resolver determines are the correct values (that's where the friend/enemy dichotomy comes into play)
I've not had an issue with rasbain (or PI OS or whatever the name is now) generating misconfigured /etc/resolv.conf files, but other distros don't play as nicely and I've had to make the file immutable with extended attributes to prevent systemd from breaking name-resolution every boot.
NM can manage the settings, but more and more systemd-resolvd seems to manager resolver configuration. (see Archwiki systemd-resolvd for details) When things don't work, it's handy to have a manual fallback to help you sort things out.
Statistics: Posted by drankinatty — Thu Oct 16, 2025 4:43 am