[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Revisiting the hostname/FQDN issue, adding libnss-myhostname



Hi Richard,

* Richard Lewis <richard.lewis.debian@googlemail.com> [2025-10-18 * 15:53]:
I think the missing bit of explanation in this thread is: why would
anyone know "apollo" but not "appollo.example.com"? both of these
strings are written by the admin in /etc/hosts which is a file that has
probably never been changed (and probably doesnt tell you anything much
about reaching the system externally)
Good point.

The hostname ("apollo") can be configured in the kernel. The libc has gethostname() and sethostname() functions to configure it, and there is a hostname tool to do so from the shell. Usually, the hostname is stored in /etc/hostname and set at boot time.

AFAIK the name is treated as an opaque string, so while Tradition tells you to set the unqualified hostname, there is no technical reason why you cannot set the fully qualified "apollo.example.com" as hostname. And some people do that; I guess it is one of the contradicting traditions Simon talked about elsethread.

ie - what is the actual problem these settings are trying to solve?
A lot of software assumes that it can always resolve the local hostname to an IP address (and vice versa look up the associated hostname of an assigned IP address). That remains true even if you set the hostname fully-qualified, so unless you have a permanent, reliable connection to a DNS server that serves your domain, you probably want the /etc/hosts entry; otherwise you may encounter random timeouts while interacting with network daemons on your host.


Cheers
Timo

--
⢀⣴⠾⠻⢶⣦⠀   ╭────────────────────────────────────────────────────╮
⣾⠁⢠⠒⠀⣿⡁   │ Timo Röhling                                       │
⢿⡄⠘⠷⠚⠋⠀   │ 9B03 EBB9 8300 DF97 C2B1  23BF CC8C 6BDD 1403 F4CA │
⠈⠳⣄⠀⠀⠀⠀   ╰────────────────────────────────────────────────────╯

Attachment: signature.asc
Description: PGP signature


Reply to: