In Mac OS X, how do I check what DNS server I'm currently using (preferably a command line solution)?

System Preferences > Network shows, which is my router's address and not the real DNS server.

  • 1
    When you use dig or nslookup command, it shows default DNS server IP address.
    – Biswapriyo
    Jul 21 '17 at 20:23
  • 2
    For the record - your router has a real DNS server. In greater detail, it's a recursing DNS server, same as your ISP's DNS or Google's
    – Nowaker
    Dec 31 '17 at 23:26
  • See also superuser.com/questions/536238/…
    – caw
    May 7 '20 at 16:11

You could try issuing the following at the command line:

scutil --dns | grep 'nameserver\[[0-9]*\]'

It should give you a list of DNS servers configured on your system.

  • that's a great command - it looks like that is the DNS server used by Comcast (my ISP). +1 for a great bonus point and what appears to be a deeper knowledge answer.
    – mbb
    Mar 16 '11 at 4:14
  • 2
    +1 For a command that shows the servers for “multi-client” configurations (e.g. /etc/resolver/…). Mar 16 '11 at 4:37
  • 2
    I've added | sort | uniq to it as I was only interested in the unique DNS servers used. Aug 23 '15 at 6:11
  • 2
    Nitpick, but why is it necessary to add \[[0-9]*\] to the grep string?
    – ijoseph
    Nov 22 '17 at 21:13
  • 1
    On my computer scutil --dns | grep nameserver is enough, or scutil --dns | grep nameserver | sort -u if I just want to see unique servers.
    – AllanLRH
    Apr 16 '18 at 10:09

Your router is acting as a DNS forwarder, you ask your router and your router asks a DNS server for you. You need to login to your router web config to figure out what it's using, or you could just enter it directly into your Network configuration.

  • This is simply wrong. A DHCP server assigns a DNS server (which is what I think you're being confused by), but a router doesn't handle DNS on its own. Its job is to route traffic.
    – senfo
    Mar 12 '18 at 0:10
  • 1
    @senfo No, Jacob is right, many routers advertise themselves as the DNS server via DHCP, and internally, they query a real (recursive) DNS server.
    – caw
    May 7 '20 at 16:10
  • 2
    @caw, I've gone back and read the comment and I think I misunderstood what the original answer was getting at. I retract my former judgement of this answer.
    – senfo
    May 7 '20 at 16:47

Use the following command to view your DNS server in Mac OS X :

Open the terminal and type

$ cat /etc/resolv.conf

to view your DNS server.

Sample output :

$ cat /etc/resolv.conf 
domain http://www.example.com (Here, you can see DNS records info of the particular domain name.)
  • 1
    This will show the same thing that System Preferences > Network does. Dec 16 '13 at 19:14
  • 3
    Not too useful nowadays. That file is only so legacy applications have something to read. Most of the MacOS stuff uses an internal database. See the reply above using the "scutil" command. Apr 21 '17 at 23:59
  • Simplicity is best. Thanks!
    – Askar
    Feb 24 '21 at 12:04

Akamai provides a DNS debugging tool which returns the IP address of the resolver used for the query. Open Terminal.app and run the following command:

dig whoami.akamai.net +short

UltraDNS also provides one, but I've found it to be less reliable:

dig whoami.ultradns.net +short

The IP address returned by these tools is a DNS resolver in use for your network, but may be only one of several. There might be an advantage to using the IP in your Network preferences directly.

You can benchmark the performance of your local and alternate DNS servers using namebench.

  • 1
    Excellent. This saves the time of accessing the router admin screen.
    – downeyt
    May 19 '15 at 14:29
  • This service is great.
    – pedrosanta
    Oct 25 '16 at 13:56

I reached to this question while I was looking for a way to get the list of DNS servers of a specific network adapter in text format (for example the Wi-Fi adapter):

enter image description here

This DNS servers list can be obtained in the terminal with this command:

$ networksetup -getdnsservers Wi-Fi

And for Ethernet adapter:

$ networksetup -getdnsservers Ethernet

That is the DNS server your mac is using. Your router is running a caching DNS server, and setting itself as the DNS server via DHCP. If you login to your router, you might be able to find out which DNS servers it uses.

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.