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

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



Timo Röhling <roehling@debian.org> writes:

> Hi,
>
> * Marc Haber <mh+debian-devel@zugschlus.de> [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.
>

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)

ie - what is the actual problem these settings are trying to solve?


Reply to: