Subject: Re: nslookup and hosts on local net
To: Mark E. Perkins <perkinsm@bway.net>
From: Jeremy C. Reed <reed@reedmedia.net>
List: netbsd-help
Date: 03/28/2002 16:52:08
On Thu, 28 Mar 2002, Mark E. Perkins wrote:

> I don't expect my ISP's name server to find a host on my network.... It
> appears to my poor brain that the man page for nsswitch.conf is saying that
> nslookup will first look in my /etc/hosts, then query DNS. If this is not

nsswitch.conf doesn't even mention "nslookup".

> what
>
> hosts:          files dns
>
> in /etc/nsswitch.conf means, then I need some help to understand what it
> really means.

Notice that the manual page says that the "hosts" database is used by
the gethostbyname(3) C library function.

So in other words, nsswitch.conf only is used by the tools that use
this gethostbyname(3) function.

The nslookup command doesn't use gethostbyname(). So nslookup doesn't use
nsswitch.conf.

By the way, nslookup(8) is consider by many to be unuseful and dead. In my
experience, it often gives misleading answers (error messages that don't
indicate what the issue really is). Maybe use dig instead. But anyways,
dig also doesn't use gethostbyname nor nsswitch.conf.

There has been discussion in the past about separate tools that do the
gethostbyname(3) job. I have a simple tool that does it (that I need to
package) and I know several other admins here have similar tools that
should be packages too :) This has been discussed a lot. One idea is
http://www.ntrnet.net/~jmknoble/software/hostinfo/

If you want mine, let me know.

$ ./gh kids
gethostbyname() took 0.055 seconds
Official hostname: "kids"
        Alias: "kids.reedmedia.net"
IP address: 192.168.0.4

   Jeremy C. Reed
   http://www.reedmedia.net/