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

Re: /etc/hosts: Two lines with the same IP address?



On Tue, Jun 08, 2004 at 05:19:29PM +0200, Thomas Hood wrote:
> On Tue, 2004-06-08 at 15:48, Andrew Suffield wrote:
> > On Tue, Jun 08, 2004 at 02:40:55PM +0200, Thomas Hood wrote:
> > >     127.0.0.1	localhost
> > >     127.0.0.1	pingo
> 
> > The above two lines *must* be precisely equivalent to *one* of the
> > following four lines:
> > 
> > 127.0.0.1 localhost
> > 127.0.0.1 pingo
> > 127.0.0.1 localhost pingo
> > 127.0.0.1 pingo localhost
> > 
> > Off the top of my head I couldn't tell you which one it is. But under
> > the NSS interface, it must be one of them, because that is what
> > gethostby*() is going to return to applications.
> 
> With
> 
>     127.0.0.1	localhost
>     127.0.0.1	pingo
> 
> if you look up "pingo" then you get "pingo" as the canonical host name;
> and if you look up "localhost" then you get "localhost" as the canonical
> host name.  That's different from getting either one or the other as
> the canonical host name for both.

Cute, albeit irrelevant. That's technically a bug (it's breaking one
of the invariants), and will probably confuse the fuck out of nscd
(which will then proceed to return "wrong" results from its
cache). However, you do not usually look at the canonical name when
you call gethostbyname() - gethostbyaddr() is the interesting case.

> > Note that #247734 contains confusing misinformation. It uses host(1),
> > which ignores /etc/hosts and uses DNS directly - and DNS can represent
> > things which NSS cannot.
> 
> The experiments with "host" were illustrations of the results you
> get from dnsmasq, which reads /etc/hosts.

Well that's a mess. I think dnsmasq is broken here, because it's
interpreting /etc/hosts improperly; NSS has no equivalent to "multiple
PTR records", and when passed through a gethostby*() call they'll get
flattened again (arbitrarily).

-- 
  .''`.  ** Debian GNU/Linux ** | Andrew Suffield
 : :' :  http://www.debian.org/ |
 `. `'                          |
   `-             -><-          |

Attachment: signature.asc
Description: Digital signature


Reply to: