Subject: Re: nslookup and hosts on local net
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: Mark E. Perkins <perkinsm@bway.net>
List: netbsd-help
Date: 03/28/2002 19:05:46
--On Thursday, March 28, 2002 23:55 +0100 Manuel Bouyer 
<bouyer@antioche.eu.org> wrote:

> On Thu, Mar 28, 2002 at 05:16:49PM -0500, Mark E. Perkins wrote:
>> How do I get nslookup to return the IP address of hosts on my local net?
>> This probably applies to gethostbyname(), as well. To be more specific:
>>
>> * I'm using 192.168.x.y addresses
>>
>> * None of my local hosts have FQDNs; they're all things like 'netbsd1'
>> 'printserver', etc.
>>
>> /etc/hosts looks thusly:
>> 192.168.1.1  netbsd1
>> 192.168.1.2  printserver
>>   (and so on)
>>
>> /etc/resolv.conf has the line:
>> lookup file bind
>> (though I understand from the man pages that this is ignored)
>>
>> /etc/nsswitch.conf has the line:
>> hosts:          files dns
>>
>> /etc/rc.conf has the line
>> domainname=""
>>
>> Nevertheless, if I say 'nslookup printserver' I get a "Non-existent
>> host/domain" error back from the name server at my ISP. (I almost never
>> want to do this, but some programs use gethostbyname() for a local
>> network  host and ending up failing....)
>
> nslookup doesn't use gethostbyname(), it does direct query to the DNS
> (it's a DNS debug tool after all, and can return much more infos than
> gethostbyname() can).
>
> gethostbyname() should honnor the nsswitch.conf settings.
> What's wrong with it ? Doesn't 'ping netbsd1' or 'ping printserver' work ?
>
> --
> Manuel Bouyer <bouyer@antioche.eu.org>
> --

'ping netbsd1' works, so I guess there's no problem with gethostbyname(), 
only a problem with my limited understanding... 8*)

'nslookup netbsd1' returns a "Non-existent host/domain" error from the ISP 
name server. So I guess my *real& question is why? Shouldn't it return the 
IP address as found in /etc/hosts?

Thanks,
Mark