1832977 Members
2742 Online
110048 Solutions
New Discussion

name resolution ?

 
Franky Leeuwerck
Frequent Advisor

name resolution ?

Hi,
When I do an nslookup of host y (which has an entry in the hosts file), I get this message.

$ nslookup y
*** Can't find server name for address z.z.z.z: Timed out
Using /etc/hosts on: hostname
looking up FILES
Name: y.xx.xx.com
Address: x.x.x.x
Aliases: y
$

Why does the system first try to find the server name of z.z.z.z ?
This z.z.z.z. is the first nameserver entry in the resolv.conf file .
10 REPLIES 10
Wim Rombauts
Honored Contributor

Re: name resolution ?

System z.z.z.z is a name server and your system is configured to contact that nameserver before looking at it's own files.

Check /etc/nsswitch.conf to see in what order your system will try to resolve names.

If DNS is in there, look at /etc/resolv.conf for the DNS server (probably z.z.z.z)

The easiest way to modify this nsswitch file is with SAM->Networking and Communications->Name Service Switch.
Remove DNS from that switch if you don't need DNS.
Steven Gillard_2
Honored Contributor

Re: name resolution ?

If you want your name resolution to use /etc/hosts first, you need to edit /etc/nsswitch.conf. Try the following:

hosts: files [NOTFOUND=continue] dns

See the nsswitch.conf(4) man page for more details.

The timeout on z.z.z.z means that name server is not responding to your request. Is this IP address in /etc/resolv.conf the correct address of your name server? If you don't need DNS, move the resolv.conf file aside.

Regards,
Steve
Eugen Cocalea
Respected Contributor

Re: name resolution ?

Hi,

Edit /etc/nsswitch.conf. Modify the hosts line like:

hosts: files [NOTFOUND=continue] dns

or (eventually) nis.

Make sure you have connection to your primary nameserver.

E.
To Live Is To Learn
Franky Leeuwerck
Frequent Advisor

Re: name resolution ?

Thanks for the replies but the nsswitch.conf is set as you guys point out :

hosts: files [NOTFOUND=continue] dns
Roger Baptiste
Honored Contributor

Re: name resolution ?

<This z.z.z.z. is the first nameserver entry in the resolv.conf file >>

nslookup follows the hosts entry defined in the nsswitch.conf file for discovering the address or hostname of a host. That's why nslookup first tries to contact the nameserver on execution. As others have pointed out,if you swap the host entry to put "files" first, it will look for /etc/hosts file (and if it cannot find the entry , it will try contacting the name server).

If you are not using namesever, then you can remove the nameserver entry. OR if you have a secondary nameserver, you can add that entry too in the resolv.conf file. That way, it will try contacting the secondary name server.

HTH
raj
Take it easy.
Steven Gillard_2
Honored Contributor

Re: name resolution ?

What are the permissions on /etc/nsswitch.conf? Is it world readable?

Cheers,
Steve
Franky Leeuwerck
Frequent Advisor

Re: name resolution ?

Ok,
The nsswith.conf is set to check the hosts file. In the hosts file the entry for host Y is present.
When doing an nslookup on y, one should expect that the system would immediately lookup the hostname in the hosts file ... but no it tries to resolve first an IP address. This doesn't seem normal.
As the last participant points out : maybe the permissions on nsswitch.conf are set wrong. I will check this asap but right now, due to network problems I cannot connect to the system.

Keep you further informed.
Franky
Sanjay_6
Honored Contributor

Re: name resolution ?

Hi Franky,

Try this entry in your /etc/nsswitch.conf file,

hosts: files [NOTFOUND=continue, TRYAGAIN=continue] DNS

Hope this helps.

Regds
Darrell Allen
Honored Contributor

Re: name resolution ?

Hi Franky,

I don't like that behaviour either but the man page says:

"nslookup is a program to query Internet domain name servers. nslookup has been extended to follow the configured name resolution algorithm of the host and to query NIS, as well as, DNS and host tables."

Seems nslookup was designed for DNS and retro-fitted for files and nis, etc. So I guess it is normal for it to connect to a DNS server even if resolving with files first.

You z.z.z.z nameserver was unavailable but nslookup had to wait to timeout before continuing.

It could be worse. I had a co-worker who was a sysadmin (I think in name only) who listed every nameserver known to him in his resolv.conf files without regard to whether or not they were behind firewalls, taken out of service, or whatever. It was amazing the things we found after he took a managerial position with another company!

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Franky Leeuwerck
Frequent Advisor

Re: name resolution ?

As I conclude from previous messages :
nslookup always looks first at the DNS even when the nsswitch.conf tells the system to look at the hosts file first.

Answering another question : the nsswitch.conf had read and write permissions for everybody.

This issue can be closed.
Thanks to all.

Franky