17

I'm trying to determine why a Nagios host check is failing (hostnames and IPs have been changed to protect the guilty):

: jmglov@laurana; host www.foo.com
;; connection timed out; no servers could be reached

: jmglov@laurana; for ns in `grep -o '\([0-9]\+[.]\)\{3\}[0-9]\+$' /etc/resolv.conf`; do ping -qc 1 $ns; done
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 10.911/10.911/10.911/0.000 ms
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.

--- 192.168.1.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.241/0.241/0.241/0.000 ms

So I know that my nameservers are reachable, meaning that some nameserver along the delegation path to the authoritative nameserver for my host is not responding. Is there an easy way to determine which nameserver this is (basically a traceroute for DNS)?

34

Does this do the job for you?

dig +trace google.com

From the man page:

+[no]trace Toggle tracing of the delegation path from the root name servers for the name being looked up. Tracing is disabled by default. When tracing is enabled, dig makes iterative queries to resolve the name being looked up. It will follow referrals from the root servers, showing the answer from each server that was used to resolve the lookup.

| improve this answer | |
  • That works a charm! – Josh Glover Mar 15 '11 at 16:01
21

For Windows you can trace your dns query with

nslookup -debug google.at

You can also trace it online (of couse from another host) on http://www.simpledns.com/lookup-dg.aspx

| improve this answer | |
  • nslookup just like dig works also under Mac OS X terminal. – Krzysztof Przygoda Oct 19 '16 at 16:17
  • This does not give the full details that I was looking for. I have my router set to use Google's DNS and I was trying to confirm that it is actually doing that and not using my ISPs DNS. If I perfrom an nslookup from the command prompt it tells me that the answer to my lookup came from 192.168.1.1, it's leaving out the intermediate steps. A dig from my linux box provides more detail, including showing 8.8.8.8 in the chain. Is there a way to do this via Windows? – BrianVPS Apr 9 at 14:03
  • This does not do the same as "dig +trace google.com" in a Linux or macOS system. It still does a recursive query to your local DNS instead of querying directly every nameserver in the trace. – Pedro Perez May 16 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.