I typically determine the IP of a host by doing: $ host -t A example.com. Is there a more verbose version of this that tells me what's happening in the background, specifically the order of what is queried (/etc/hosts 1st, dns server 2nd)?

As many people can attest to, OS X Lion resolves local /etc/hosts entries painfully slowly, and I'd like to see what bottlenecks are causing this. Seems like in theory, /etc/hosts should be queried first and name resolution should happen instantaneously for manually entered hosts.


Since Apple has done away with nsswitch.conf in Lion, you can view the resolver order with scutil --dns.

My guess is you will see "DNS" listed before "local".

It's a bit of a hack, but you can install DNSMasq on your OS X host and have your system query it for DNS resolution. DNSMasq can read /etc/hosts first and serve up the entries it finds there before searching DNS. This restores the proper order to resolution.

The gentleman who wrote this blog has done all of the hard work for you. He describes how to install DNSMasq and configure it on OS X Lion.

  • 1
    ... Why in the name of Saint Carl the Far-Seeing and Saint Frederick the Compassionate did they dump a perfectly functional resolution mechanic in exchange for scutil ? – Shadur May 15 '12 at 8:25
  • @Shadur just remember they have their own keyboard layout and have given up on non-glossy displays, that should suffice to understand... – Shadok May 15 '12 at 12:09
  • @Shadur Ask Different. apple.stackexchange.com :) – George M May 15 '12 at 12:48

I find dig particularly useful in that realm. The default output is verbose and shows what is being done (what gets sent and what is received.)

There is an example:

alex$ dig m2osw.com

; <<>> DiG 9.10.3-P4-Ubuntu <<>> m2osw.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52965
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 512
;m2osw.com.         IN  A

m2osw.com.      85160   IN  A

;; Query time: 18 msec
;; WHEN: Sun Aug 19 18:02:58 PDT 2018
;; MSG SIZE  rcvd: 54


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.