On Sun, Jun 26, 2022 at 04:32:38PM -0400, Jim Popovitch wrote: > where does `hostname -f` derive the domainname from?
Start with the man page, always. -f, --fqdn, --long Display the FQDN (Fully Qualified Domain Name). A FQDN consists of a short host name and the DNS domain name. Unless you are us‐ ing bind or NIS for host lookups you can change the FQDN and the DNS domain name (which is part of the FQDN) in the /etc/hosts file. See the warnings in section THE FQDN above und use host‐ name --all-fqdns instead wherever possible. So, the initial point is /etc/hosts (as it says in the text). Now let's check out the warnings it told us to heed. THE FQDN [...] The recommended method of setting the FQDN is to make the hostname be an alias for the fully qualified name using /etc/hosts, DNS, or NIS. For example, if the hostname was "ursula", one might have a line in /etc/hosts which reads 127.0.1.1 ursula.example.com ursula [...] Both sections are vague and murky about what happens if you *don't* have an entry for your hostname in /etc/hosts. Fortunately, Debian adds a line exactly like this in /etc/hosts, for your hostname with your "DNS domain name" (the one you specified during installation) attached. So you rarely ever have to worry about what happens if this entry is missing. My understanding is that if you mangle your /etc/hosts file so that there is no entry of this form, it'll move on to a DNS lookup next (following the steps outlined in /etc/nsswitch.conf). A DNS lookup of your short-form hostname (with no dots in it) would typically apply the domain names that are specified in /etc/resolv.conf in the "search" entry -- or if there is no search entry, then the legacy "domain" entry. If you have also mangled the /etc/nsswitch.conf file so that name lookups are performed using alternative sources, then you would be the sole person who knows where to look.