When querying a particular address, dig as run against the resolvers listed in /etc/resolv.conf will return NXDOMAIN nice and quickly where host will take a while.

$ dig @<resolver> ptr

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @<resolver> ptr
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 40000
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;    IN  PTR

;; Query time: 1 msec
;; SERVER: <resolver>#53(<resolver>)
;; WHEN: Wed Oct 22 16:08:38 2014
;; MSG SIZE  rcvd: 44

But much slower in host...

$ time host <resolver>
;; connection timed out; no servers could be reached

real    0m12.007s
user    0m0.001s
sys 0m0.007s

Why does host take so long to come up with the same answer?

  • That is not the same answer. dig got an NXDOMAIN response, host got no response at all. – Håkan Lindqvist Oct 22 '14 at 16:59
  • It's also worth noting that it was not the same query that you asked the two programs to perform. dig was asked to look up while host was asked to look up (both with type PTR). – Håkan Lindqvist Oct 22 '14 at 17:06

Your two commands are not equivalent.


is equivalent to:

dig ptr

The labels in PTR records are the elements of the IP address in reverse.

Since you're looking up the reverse DNS of different IPs, they're trying to reach different DNS servers. So the timing will naturally be different. And in your example, the reverse DNS server for 199.80.140.in-addr.arpa isn't responding, so you get a timeout.

To avoid having to reverse the IP by hand, you can use the -x option as a shortcut:

dig -x

This option also defaults to PTR lookup, so you can omit that argument as well.

  • Ugh, end of a long day. Thank you for spotting the deliberate mistake ;) Also thanks for the -x option, very handy! – Merlin83b Oct 23 '14 at 11:05

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.