
| Msg # 1117 of 1179 on ZZLI4422, Friday 10-23-25, 10:15 |
| From: THORSTEN GLASER |
| To: DOWNLOADING POSTS AS MBOX |
| Subj: Re: Revisiting the hostname/FQDN issue, |
From: tg@debian.org
Someone (not clear from the web view, and l.d.o does not allow
downloading posts as mbox like the BTS does) wrote:
> why we are writing an /etc/hosts with "127.0.1.1 apollo.example.com apollo"
Hah! *rubs hands* Hostnames on unixoid systems a pet peeve.
First off, that 127.0.1.1 has to go. There are active changes
underways to change the 127/8 allocation to an 127/24 one, to
free more IPv4 addresses. (Just passing on, dont talk to me
about this one.)
Then.
/etc/hosts.
Ive worked best with the following setup:
1. If any IP or Legacy IP address is statically assigned to
the box (inet static/inet6 static in /e/n/i, or even
its known that the host has a reservation on the dhcpd)
then add lines of the form $ip $fqdn ${fqdn%%.*}"
2. If there is any Legacy IP statically assigned as in 1,
then add additionally 127.0.0.1 localhost,
else add additionally 127.0.0.1 $fqdn ${fqdn%%.*} localhost
3. Add the remaining IP entries like ::1
Additionally, /etc/{host,my}name or however the OS calls the file
the kernel nodename is loaded from (which will be the result of the
bare hostname command without -f/-s) must co
tain the FQDN! This
is not what Debian currently does but is necessary and will lead to
only minor fallout (like the FQDN shown in the too-short field of
KDMs greeter) thats easily handled by s/\\..*$// in affected code,
but will result in a MUCH better overall operation.
The /etc/domainname or whatever fills the kernels domainname must
be empty or n
n-existent, as thats only used for NIS/YP, which you
dont use. (If you do, find something that works for you because I
have no setup of that.) This means a bare domainname will return
(none) or not echo anything (like true(1)).
I also tend to have search ${fqdn#*.} [other relevant domains]
in /etc/resolv.conf.
This setup has fixed things like the MTA needing minutes to start
(or to run newaliases) because it could not resolve the hostname,
hostname/domain confusion, etc. It also has the benefit that the
canonical FQDN of the system is available at all and independent
of external factors, and available without having to do a DNS
query, which has proven massively beneficial (the short hostname
is of course trivially cut off at the first point, hostname -s).
I almost want to say let the flames begin, and Nik will likely
respond that he disagreed years ago with this already, but this is
how I run all unixoid systems (various BSDs, decades of Debian,
SuSE old and new, RHEL and related distros, and the occasional
other unixoid I ran). If this is to be revisited in Debian anyway,
and likely (due to the 127/8 reallocation) needs change anyway, I
wanted to contribute what I personally believe is the best setup.
As such Ill not take flames (and likely not respond because Im
not subscribed to d-devel due to the high traffic anyway).
Its early enough in the release cycle that such a switch and the
fixing of those softwares that need a cut off implemented can
still happen.
or 127.0.0.1 localhost localhost.localdomain, though I
only picked up the latter on GNU systems
or 127.0.0.1 $fqdn ${fqdn%%.*} localhost localhost.localdomain,
I currently am using the following:
::1 ip6-localhost ip6-loopback localhost6 localhost6.localdomain6
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I picked these up, again, mostly on GNU systems (Debian and RPM kinds)
and dropped bare localhost from it; things currently overall tend to
work slightly better if localhost only resolves to 127.0.0.1 and not
to ::1 (as well or only). Again, that localhost6.localdomain6 likely
isnt needed
In my next overhaul of my mkhosts script Ill probably drop both
the
localhost.localdomain and localhost6.localdomain6; one of the
donts
Ive seen is localhost{,6}.${fqdn#*.} which is similarily useless
so
do not add that either.
HOSTNAME=host.example.com in /etc/sysconfig/network on RHEL
So, for the above-mentioned apollo system, heres sample configs.
/etc/hosts when apollo has dynamic IPs (DHCP, rtsol) only:
127.0.0.1 apollo.example.com apollo localhost
::1 ip6-localhost ip6-loopback localhost6
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
/etc/hosts when apollo has static IPs:
127.0.0.1 localhost
192.168.1.2 apollo.example.com apollo
172.17.0.1 apollo.example.com apollo
2001:db8:0:cafe:: apollo.example.com apollo
2001:db8:0:cafe::0200:5eff:fe00:5300 apollo.example.com apollo
::1 ip6-localhost ip6-loopback localhost6
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
(The example has an internal (Docker) and an external Legacy IP
static, an EUI64-based IP and the anycast network router.)
/etc/hostname
apollo.example.com
No /etc/domainname or an empty one.
/etc/resolv.conf
search example.com example.org
nameserver 9.9.9.9
$ cat /proc/sys/kernel/hostname # Linux
apollo.example.com
$ cat /proc/sys/kernel/domainname
(none)
$ sysctl kern.{host,domain}name # BSD
kern.hostname=apollo.example.com
kern.domainname=
Hope this helps.
bye,
//mirabilos
--
Having a smoking section in a restaurant is like having
a peeing section in a swimming pool.
-- Edward Burr
--- SoupGate-Win32 v1.05
* Origin: you cannot sedate... all the things you hate (1:229/2)
|
328,084 visits
(c) 1994, bbs@darkrealms.ca