1752782 Members
6161 Online
108789 Solutions
New Discussion юеВ

Re: DNS

 
Wilfred Chau_1
Respected Contributor

DNS

I came across a wried situation.

The nsswitch.conf is configured to use /etc/hosts file only. But when the /etc/resolv.conf does not exist, nslookup/dig took a long time to run then it timed out and returned nothing, even though there is an entry in /etc/hosts.

Do you know how to fix this? thx.
9 REPLIES 9
Alexander Chuzhoy
Honored Contributor

Re: DNS

/etc/nsswitch.conf defines what to use host/ip resolution, but both dig and nslookup are DNS lookup utilities and basically require or check DNS .
Wilfred Chau_1
Respected Contributor

Re: DNS

not true, if you have configured nsswitch.conf for hosts to look for only files(/etc/hosts)?
Heironimus
Honored Contributor

Re: DNS

No, nslookup and dig don't care how nsswitch.conf is set up. They are specifically for doing DNS queries and can not operate against any other name services.

Some versions of "host" use the system resolver and will honor the settings in nsswitch.conf, but on my RHEL4 systems host still only uses DNS.
Ivan Ferreira
Honored Contributor

Re: DNS

As Alexander said, nslookup, dig, host commands relies on DNS, even if nsswitch states that only local files should be used. The program that explicitly open /etc/hosts will resolve the hosts listed. See this related thread:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1110957
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Steven E. Protter
Exalted Contributor

Re: DNS

Shalom,

Every system needs an /etc/resolv.conf file. Put one in that says this:

nameserver 127.0.0.1

Also, add dns as a second line to the hosts lookup entry in /etc/nsswitch.conf

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
Wilfred Chau_1
Respected Contributor

Re: DNS

updated /etc/resolv.conf with working nameservers.

Place files first in /etc/nsswitch.conf for hosts.

However, nslookup/dig of hostname/ip listed in /etc/hosts failed.

this is wried....
Steven E. Protter
Exalted Contributor

Re: DNS

What about ping?

I've seen situation where dig/nslookup worked and ping did not and weirdly the reverse.

Why don't you upload /etc/nsswitch.conf I suspect something strange going on.

You might also want to make sure you have only one GATEWAY entry in either /etc/sysconfig/network or the ifcfg file in /etc/sysconfig/network-scripts directory.

No GATEWAY entry can cause this kind of network weirdness. Two GATEWAYS can as well.

I won't be looking at the upload for a bit, its bedtime.

:0

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
Wilfred Chau_1
Respected Contributor

Re: DNS

#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
# compat Use compatibility setup
# nisplus Use NIS+ (NIS version 3)
# nis Use NIS (NIS version 2), also called YP
# dns Use DNS (Domain Name Service)
# files Use the local files
# [NOTFOUND=return] Stop searching if not found so far
#
# For more information, please read the nsswitch.conf.5 manual page.
#

# passwd: files nis
# shadow: files nis
# group: files nis

passwd: compat
group: compat

#hosts: files dns
hosts: files [NOTFOUND=return]
#networks: files dns
networks: files

services: files
protocols: files
rpc: files
ethers: files
netmasks: files
netgroup: files nis
publickey: files

bootparams: files
automount: files nis
aliases: files
Jeroen Peereboom
Honored Contributor

Re: DNS

Wilfred,

as stated by others: on LINUX, nslookup and hosts do not read the nsswitch.conf file.
I know on HPUX nslookup (there is no 'hosts' command on HPUX) does follow the nsswitch.conf.

But not on Linux. And also not on Solaris.
That's the way it is?!

JP.