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.