Comment 23 for bug 19775

Revision history for this message
Thomas Hood (jdthood) wrote :

Dennis Kaarsemaker wrote:
> The line that should read
> 127.0.0.1 localhost.localdomain localhost myhostname

No it should not. Read section 10.4 of the Debian reference which also applies to Ubuntu.

    http://www.debian.org/doc/manuals/reference/ch-gateway.en.html

In general, it is important that the current system hostname be resolvable in /etc/hosts
to an IP address and back from that IP address to the same hostname or to a fully
qualified variant thereof.

This will not happen if the hostname is included as an alias for "localhost" because then
the hostname -> IP address -> canonical hostname lookup sequence will yield "localhost".

In other words, in /etc/hosts, the "127.0.0.1" line should look like this:

    127.0.0.1 localhost

Do not put "localhost.localdomain" on this line. That is a RedHat-ism. It is not needed
in Debian and Ubuntu.

Assign the current system hostname (e.g., "foo") a permanent IP address if the machine
has one, e.g.,

    138.64.21.258 foo.bar.com foo

and assign it the loopback address 127.0.1.1 if it does not:

    127.0.1.1 foo

Note the difference between 127.0.1.1 and 127.0.0.1.

To those who suggest putting the system hostname ("foo" in our example) on both
the 127.0.0.1 line and the 127.0.1.1 line: No, that is an invalid configuration. Each
host name should be associated in /etc/hosts with a single IP address.

What I describe above are /etc/hosts configuration standards for Debian and Ubuntu.
In the real world many people are confused about how /etc/hosts should be set up
and this includes many Debian and Ubuntu developers, and even those developing
and packaging network configuration tools. I haven't looked recently, but up until
two years ago there was no network configurator that even came close to writing
valid network configuration files in Debian and Ubuntu. For a very long time I have
avoid installing or starting network configuration tools in Debian and Ubuntu.