When looking up the address for
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
dig so much faster than
nslookup? What is
nslookup doing /
dig not doing that takes so long?
$ 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?