1822002 Members
3880 Online
109639 Solutions
New Discussion юеВ

Nslookup and hosts file

 
Phillip Todd
Advisor

Nslookup and hosts file

Hi Running V11.00

When I do an nslookup on local host, server states cannot resolve name although there is a fully qualified name in the hosts file. It appears to be going to the DNS server.
I have an switch and resolve files with entries
Why does the server not look in the host file first
Many Thanks
7 REPLIES 7
Luk Vandenbussche
Honored Contributor

Re: Nslookup and hosts file

Modify the file /etc/nsswitch.conf

add or modify

hosts: files
Fabio Ettore
Honored Contributor

Re: Nslookup and hosts file

Hi,

as Luk said you can do that in /etc/nsswitch.conf. This file doesn't exist for default, so if you don't see it then you have to create a new one (or copy from /usr/newconfig/etc, you will see there some nsswitch.* templates).
Anyway in your instance you should solve the problem when modyfing the line 'hosts' as follows:

hosts: files [NOTFOUND=continue] dns

This will look in /etc/hosts before and then in DNS.

Best regards,
Fabio
WISH? IMPROVEMENT!
perumal_2
Frequent Advisor

Re: Nslookup and hosts file

Hi

As Luk & Fabio said you can change the entries in the /etc/nsswitch.conf file

or you can use SAM to change the name service switch order.
In Sam
networking and Communications ->
name service switch ->
where you can specify the name service lookup order.
Beware SAM will reboot the system after you configure, but it will givge you an idea of understanding how & what are all available in name service lookups.

TQ
Perumal
Steven E. Protter
Exalted Contributor

Re: Nslookup and hosts file

Shalom,]

For DNS to work the servers must have the answers or access to the answers being requested.

To get hosts resolution to work /etc/nsswitch.conf must be modified as noted above.

In a quirk that never made sense to me, HP-UX installs with no nsswitch.conf file. There are several candidates with different names in the /etc directory, but the systemadmin is required to pick one, or write his/her own and put it in production.

Why there is no default mystifies me.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Senthil Kumar .A_1
Honored Contributor

Re: Nslookup and hosts file

Just a point adder for future,..

To always know the search order currently in effect for look ups...

run command "nslookup" with out any options..

Then in the nslookup command prompt.. type "policy...

ex:
root@XXXXX# nslookup
Using /etc/hosts on: XXXXX

> policy
#Lookups = 2
files [RCCC] dns [RRRR]

R means retry, C means continue, There are other settings aswell refer "man nsswitch.conf"... The above output is a reflection of configuration set in nsswitch.conf...
...For the solution of your problem please refer to previous responses.....
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Bill Hassell
Honored Contributor

Re: Nslookup and hosts file

Another resolver tool is nsquery. It gives a bit more detail in how your system resolves network names, something like this:

nsquery hosts www.hp.com


Bill Hassell, sysadmin
Jim Keeble
Trusted Contributor

Re: Nslookup and hosts file

There are lots of fixes in PHNE_28449 , the bind 4.9.7 patch, for nslookup. I didn't have time to do a thorough search to match your symptoms exactly, but it did sound familiar.

If you don't have the patch, you might give it a try, no guarantees though.