[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
> localhost.localdomain localhost
> or
> 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 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; this is because it is listed before
localhost.  If /etc/hosts were changed to: localhost localhost.localdomain

Resolution of 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 to localhost.  However, consider the following two

1 -- When configuring DNS, must resolve to localhost and vice
versa [1].  Configuring an /etc/hosts file that resolves to
localhost.localdomain is inconsistent.  On the same host, resolving 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: 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

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



Reply to: