How can I display the current DNS servers from the command line under OS X?
Solution 1:
There are several ways - here are two:
cat /etc/resolv.conf
-or-
scutil --dns
Solution 2:
The following shell command can be useful to list the current DNS entries:
grep nameserver <(scutil --dns)
To filter it out for the script, you can pipe the output into awk '{print $3}'
or grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"
command.