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

Re: localhost.localdomain

On Fri, 2005-10-07 at 16:26 +0200, Christoph Haas wrote:

> The problem is probably that the "localhost.localdomain" stands before
> "localhost" in that line. So if you "reverse resolve" you
> end up with "localhost.localdomain" which some applications don't understand.

Christopher hits the nail on the head.  There are two separate issues:

1 - Is there a reason to have localhost.localdomain
2 - If there is localhost.localdomain should *not* precede localhost!

I'm not going to comment on the former but the latter is a *BIG* deal.
The current Debian /etc/hosts file is flat out wrong.  When a call to
gethostbyname(3) or gethostbyaddr(3) and an IPV4 address of is
supplied, it should return "localhost".  Provided resolv.conf is
configured to use files and then dns, gethostbyname/gethostbyaddr is
going to query /etc/hosts.  In /etc/hosts multiple hostnames can be
assigned to a single address, but when resolving an address to a
hostname, the *first* hostname in the list is returned by

Every sane implementation of IP returns "localhost" when querying  It doesn't matter if the implementation
uses /etc/hosts, /etc/inet/hosts, /boot/beos/etc/hosts, or (*gulp*) c:

Of course, other systems ship with a default hosts file containing
something in addition to "localhost" that resolves to  The
issue with Debian is that "localhost.localdomain" comes *before*
"localhost".  A call to gethostbyname() to resolve localhost returns a
struct referring to  A call to gethostbyname() to resolve
127.0.01 returns a struct referring to localhost.localdomain.  This is

This has been mentioned before, but I'll say it again.  This is solely
because the Debian /etc/hosts reads:       localhost.localdomain localhost

"localhost.localdomain" and "localhost" must be swapped.  The first
entry in the list of hosts *must* be "localhost".

Just as a sanity check, Solaris ships with:	localhost loghost

FreeBSD ships with:       localhost localhost.my.domain myname.my.domain

I don't have access to AIX, HPUX or other major Unices, but I bet in the
hosts file, is immediately followed by localhost -- and other
aliases follow localhost.  "localhost" *must* be first.


Reply to: