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.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityIn 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.
/etc/resolver/…
).
Mar 16, 2011 at 4:37
| sort | uniq
to it as I was only interested in the unique DNS servers used.
Aug 23, 2015 at 6:11
\[[0-9]*\]
to the grep
string?
scutil --dns | grep nameserver
is enough, or scutil --dns | grep nameserver | sort -u
if I just want to see unique servers.
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
System Preferences > Network
does.
Dec 16, 2013 at 19:14
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
ipconfig getoption en1 domain_name_server
works? Where "en1" is one of interfaces listed by ifconfig -l
.
Jul 21, 2022 at 18:02
ipconfig
command above doesn't give any feedback at all. ifconfig -l
gives this feedback: lo0 gif0 stf0 anpi0 anpi1 anpi2 en4 en5 en6 en1 en2 en3 ap1 en0 awdl0 llw0 bridge0 utun0 utun1 utun2
. I'm only running Monterey as it's the oldest OS which the MBP M1 Pro series will run.
Jul 22, 2022 at 0:47
networksetup -listallnetworkservices
and networksetup -getdnsservers Wi-Fi
May 10 at 6:49
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.