Re: name resolution for ping different?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Jeremy C. Reed
Date:  
To: Main PLUG discussion list
Subject: Re: name resolution for ping different?
On Fri, 19 Jan 2007, Dazed_75 wrote:

> > ping and traceroute use gethostbyname to do the name lookup. While dig
> > and nslookup use DNS directly.
>
> Should I have known or been able to learn this easily in some fashion? I
> had assumed there was a difference but had no clue where to look to find the
> difference.


Not documented quickly. Just assume that anything that does a name lookup
uses gethostbyname(3) or reverse with gethostbyaddr(3) (well some may use
getaddrinfo() or getnameinfo).

While dig and nslookup "interrogat[e] DNS name servers" and "query
Internet domain name servers" specifically.

You can learn about this on your Ubuntu system by looking at "hosts" man
page which points to resolver(3) and resolver(5) man pages. But
resolver(3) is not installed by default and resolver(5) is not applicable
for this.

Also look at nsswitch.conf man page.

And:

reed@ubuntu:~$ grep hosts /etc/nsswitch.conf 
hosts:          files dns mdns


(I mostly use systems that include man pages for resolver(3) and
gethostbyname(3) by default. :)

> > So start by looking at /etc/hosts and then /etc/resolv.conf.
>
>
> We did check /etc/hosts and cleaned it up and later rebooted. I was not
> sure if the file might be cached or how to force a re-read so the reboot was
> to ensure that. I did not think to check /etc/resolv.conf since we were
> able to surf the net. But now I think on it maybe we were bypassing dnsmasq
> on the router and going directly to the ISP dns servers. I will ask the
> owner to check this. I would have thought though that /etc/resolv.conf
> would have been updated as a result of the DHCP request when the system was
> rebooted. Am I wrong there?


You never know unless you check. There may have been some problem with
overwriting the resolv.conf.

Also /etc/hosts can be edited and I never heard of it being cached (if
file changes).

You may also want to use "tcpdump" to watch DNS traffic to get any idea
where it is getting the information.

If you want, give my gethost tool a try:
http://www.reedmedia.net/software/gethost/

Jeremy C. Reed
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss