Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What command line command do I use to lookup a domain address?

When looking at the man pages for nslookup and dig I can see a section saying that these utilities do not use the Mac OS methods of finding names.

So, what command should I be running?

share|improve this question
up vote 20 down vote accepted

nslookup, host, and dig are perfectly good DNS query tools in OS X, but they all query DNS directly rather than going through OS X's internal resolution system. As a result, they don't check the /etc/hosts file, or resolve Bonjour/mDNS names (those ending in .local). The standard (quick 'n dirty) way to test resolution is to use ping, since it'll resolve the address you give it through the usual system before attempting to ping it. If you want something intended for the purpose, use dscacheutil instead:

$ dscacheutil -q host -a name

$ ping
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=57 time=57.258 ms
--- ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 57.258/57.258/57.258/0.000 ms
share|improve this answer
Kudos. I've filed a Radar that the manpages should be clearer on this: – Sören Kuklau Dec 4 '15 at 8:37

Either command works fine. Just because it's not using OS X's methods doesn't mean that it doesn't work. If you want to use "OS X methods" may I recommend Network Utility?

enter image description here

This may still call whois and just display it in the window.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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