Get DNS Server IP Addresses from the Command Line in Mac OS X
You can quickly retrieve active DNS server IP addresses on any Mac by using the networksetup utility. Launch the Terminal and type the following:
Mac OS X 10.7 Lion:
networksetup -getdnsservers Wi-Fi
Mac OS X 10.6 Snow Leopard and before:
networksetup -getdnsservers airport
Note that I’m specifying ‘airport’ because I primarily use a wireless connection, but you could also specify ethernet and bluetooth.
Assuming there are several DNS servers set within Mac OS X’s networking preferences, you will see a report of each DNS server in the order of their priority, looking something like this:
For those wondering, the top most DNS IP in that sample list is Google’s Public DNS, the next two are from OpenDNS, with the last being a local router. If you need to, you can use a free utility like namebench to find a fast DNS server.