In Mac OS X, how do I check what DNS server I'm currently using (preferably a command line solution)?
System Preferences > Network shows 192.168.1.1, which is my router's address and not the real DNS server.
In Mac OS X, how do I check what DNS server I'm currently using (preferably a command line solution)?
System Preferences > Network shows 192.168.1.1, which is my router's address and not the real DNS server.
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.
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.)
nameserver 68.87.85.98
nameserver 68.87.69.146
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
dnsleaktest.com provides the same results via a web interface.
The IP address returned by these tools is a DNS resolver in use for your network, but may be only one of several.
You can benchmark the performance of your local and alternate DNS servers using namebench.
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.
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):
This DNS servers list can be obtained in the terminal with this command:
$ networksetup -getdnsservers Wi-Fi
8.8.8.8
4.2.2.4
4.2.2.1
4.2.2.2
192.168.1.1
And for Ethernet adapter:
$ networksetup -getdnsservers Ethernet
8.8.8.8
4.2.2.4
4.2.2.1
4.2.2.2
192.168.1.1
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.
Please update the article, for macOS Sequoia !, and IF YOU CHANGE THE DNS-SERVER, EMPTY THE DNS-CACHE, BY TYPING THE FOLLOWING COMMAND INTO THE TERMINAL APP :
dscacheutil -flushcache
.