0
When looking up the address for localhost
, nslookup localhost
takes ~15 seconds:
$ /usr/bin/time nslookup localhost
;; connection timed out; no servers could be reached
Command exited with non-zero status 1
0.00user 0.00system 0:15.00elapsed 0%CPU (0avgtext+0avgdata 4072maxresident)k
0inputs+0outputs (0major+1121minor)pagefaults 0swaps
dig localhost
is immediate.
$ /usr/bin/time dig localhost
; <<>> DiG 9.9.5-3ubuntu0.17-Ubuntu <<>> localhost
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20936
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;localhost. IN A
;; ANSWER SECTION:
localhost. 0 IN A 127.0.0.1
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed May 09 08:53:37 UTC 2018
;; MSG SIZE rcvd: 43
0.00user 0.00system 0:00.07elapsed 6%CPU (0avgtext+0avgdata 4244maxresident)k
320inputs+0outputs (1major+1164minor)pagefaults 0swaps
Why is dig
so much faster than nslookup
? What is nslookup
doing / dig
not doing that takes so long?
Incidentally:
$ grep localhost /etc/hosts
127.0.0.1 localhost
The fact that nslookup
is failing is down to a configuration issue: /etc/resolv.conf
contains an extra search
suffix, which is being forwarded to a non-existent resolver.
My question is: why the difference?
In your own output nslookup is failing so that isn't a meaningful comparison. For me both commands are near instant. – jdwolf – 2018-05-09T09:34:09.843
dig
andnslookup
both take around 10ms for me. as @jdwolf pointed out, your output shows thatnslookup
is timing out, hinting at a configuration issue. – Attie – 2018-05-09T09:42:01.493I know it's a configuration issue. My question is why the difference? I've updated the question. – Roger Lipscombe – 2018-05-09T10:06:01.857