From: roehling@debian.org
Hi,
* Marc Haber [2025-10-13 22:22]:
>The biggest question that I still have is why we are writing an
>/etc/hosts with "127.0.1.1 apollo.example.com apollo". Without that,
>the FQDN of the system is incorrect. But why 127.0.1.1? Arch Linux does
>it the same way, but they don't explain why, either.
Even though most people associate 127.0.0.1 with the loopback interface,
the whole 127.0.0.0/8 block is actually reserved for that purpose, and
*any* address in that block loops back to your own host (just for fun,
try "ssh 127.234.56.78" if you have an SSH server running on your
computer).
127.0.1.1 is not special, it merely happens to be an address that
a) maps to your own host, and
b) has no other name assigned to it which would conflict in a reverse
lookup (127.0.0.1 is mapped to "localhost").
The usual "trick" to get your own domain name is via hostname
canonicalization, i.e, you run gethostbyname("apollo"), which returns
127.0.1.1, and afterwards gethostbyaddr(127.0.1.1), which returns
"apollo.example.com". The 127.0.1.1 entry in /etc/hosts makes this work
and still lets the software on your computer behave exactly as if your
computer had a static IP with a proper DNS entry, regardless of your
actual network setup.
>And why do we handle systems that get installed with IP
>autoconfiguration in a different way than we do for systems with their
>IP statically set. Should we not generate the 127.0.1.1 line even in
>the latter case? Do we, maybe?
I don't see any reason not to. I for one configured /etc/hosts that way
on all servers I set up. Maybe someone else has additional insight.
If you ask me, the roaming client is the more problematic case, as you
need to have a well-defined FQDN to generate the /etc/hosts entry. I
suppose it can be a bit awkward if you want the domain name to be
configured dynamically and the DHCP client has to rewrite /etc/hosts
each time you connect to a network, which is probably why systemd is
exploring alternative resolution mechanisms.
Cheers
Timo
--
Timo Rhlin
9B03 EBB9 8300 DF97 C2B1 23BF CC8C 6BDD 1403
F4CA
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEmwPruYMA35fCsSO/zIxr3RQD9MoFAmjtdYEACgkQzIxr3RQD
9MpKiQ//ZJPFLQJh/fFuvvCOc2duxqdeS2rL9F2LHCIQXsfqW5BTJpOVu/Kv4LZq
xRYd9FCdJnYYKNvaaX1qO8WaNmr/DU//EKuKh5nW1O846sYJWmybAYo8wPXCZTnW
N/oLJBdatN2hl42o6DJ2+WeL1UriBKYkBPxO97dTxLvDjZz3xiikYIOlcR0tURl4
qgf8QUnhtL/s/DCahFEdyHHnl/G/e08Hz4UfgoaGjHkYdEN+uqD5/TO2t72qwdg9
KLVWa2VbyU74c5O3Tp7IySxJEQe6zTOp4gu0wMZqCTRxspRopnTlaehE+18H1NzO
t5JibVVqK2pangHR3OzK5YA+fyq+/N1wh+bxkwfIev1pRjBWqNvmcUGWqeO9eGBl
AIXr5vzpr99KdtjUC5VfF5BKiHiTd5XAjZxYDyT05LNFUB20W0A2f01G5dP53jXK
7cGTf1zXzRSb41W4hO4dVSlie5ImDevJb6zaVLn9X3ieCEEqB71aNXM23joxQUiL
xI51Qs5U3TAczX02R69l0UuuijguiCgmmZTunyRKsq90ntF1nLCOVNpLf3emBPCJ
HS+hCS15U8NQh/l99GUMFCoEgGenYW/M/mrHXSnIdML0DU7L62+G63Ijs7l1Py+X
IH4h0X4bUPqGbSaRtnFnZckJOy5ihXf0fO/GoD0XT5V4xGLk5b4=
=cX05
-----END PGP SIGNATURE-----
--- SoupGate-Win32 v1.05
* Origin: you cannot sedate... all the things you hate (1:229/2)
|