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

Re: localhost.localdomain



On Thu, 2005-10-13 at 16:02 +0200, Thomas Hood wrote:
> The change from 'localhost' to 'localhost.localdomain' was made in
> svn revision 16759.  The Debian changelog entry added at that time
> refers to bug report #247734.  Looking at #247734 I see that
> 'localhost.localdomain' appeared without anyone either supporting
> its inclusion or objecting to it.  This wasn't what the conversation
> was about.
> 
> I see no reason not to revert the change.  If the presence of
> 'localhost.localdomain' causes trouble and if standard practice is
> to have 'localhost' only then I think that that is reason enough to
> revert.
> 
> However, I think that applications should work properly whether
> /etc/hosts contains
> 
>     127.0.0.1 localhost.localdomain localhost
> 
> or
> 
>     127.0.0.1 localhost
> 
> especially considering the fact that the sarge installer writes
> /etc/hosts with the former.
> -- 
> Thomas Hood

Others on this list have pointed out that some applications expect
127.0.0.1 to resolve to localhost.  When the resolver uses /etc/hosts,
it returns the first host in the list and the others are considered
aliases.  In the first example above, localhost.localdomain would be
returned when resolving 127.0.0.1; this is because it is listed before
localhost.  If /etc/hosts were changed to:

127.0.0.1 localhost localhost.localdomain

Resolution of 127.0.0.1 would properly return localhost.  

I've been unable to find any specific reference to a required structure
of a hosts file nor any specific requirement that a resolver should
resolve 127.0.0.1 to localhost.  However, consider the following two
points:

1 -- When configuring DNS, 127.0.0.1 must resolve to localhost and vice
versa [1].  Configuring an /etc/hosts file that resolves 127.0.0.1 to
localhost.localdomain is inconsistent.  On the same host, resolving
127.0.0.1 by gethostbyname() and running nslookup will return two
different answers (provided nsswitch.conf is configured with "files
dns").  [1] RFC 1912 - http://www.ietf.org/rfc/rfc1912.txt

2 -- Virtually all systems with a hosts file read something like this:
        127.0.0.1 localhost <alias> <another alias> <...>
There is a long historical precedent for listing localhost first,
followed by other aliases.  This results in the resolver properly
returning localhost when resolving 127.0.0.1.

In summary: (1) It's reasonable to expect DNS and file based resolution
to function the same in regard to 127.0.0.1/localhost (proper DNS
resolution of 127.0.0.1 is documented in RFC 1912).  (2) There is a long
historical precedent for localhost preceding all aliases of 127.0.0.1 in
a hosts file.

Thanks!

-Jeff  





Reply to: