127.0.1.1 in /etc/hosts
Colin Watson
cjwatson at ubuntu.com
Thu Nov 30 11:11:18 UTC 2017
On Wed, Nov 29, 2017 at 04:11:58PM -0500, Tom H wrote:
> "127.0.0.1" should resolve to "localhost" and "localhost" should
> resolve to "127.0.0.1". Debian's been using "127.0.1.1" since 2005 for
> the system's hostname.
>
> In 2005, AFAIR, Thomas Hood proposed an nss module that would resolve
> the system's hostname to 127.0.1.1 so as not to have an entry for it
> in "/etc/hosts" (which is exactly what Lennart's "nss-myhostname" -
> called "libnss-myhostname" in Debian and Ubuntu - does, but with
> 127.0.0.2). There was pushback so he proposed adding a "127.0.1.1
> system_hostname" line to "/etc/hosts". This was accepted and it became
> the Debian and Ubuntu default.
Indeed. Minor correction: this is only the case if the installer hasn't
been told that the system has a static IP address.
The overall goal here is that it should always be possible to round-trip
the system's hostname through name<->address lookups. (If the hostname
were mapped to 127.0.0.1, then that wouldn't work because of the
collision with localhost, so it's useful to take advantage of the fact
that the lo interface has all of 127/8.)
--
Colin Watson [cjwatson at ubuntu.com]
More information about the ubuntu-users
mailing list