MacOS – How to display in console the domain names used by the OS X 10.10 DNS resolver

dnsmacos

I want to display the list and order of domains used by the resolved on OS X 10.10.

I know that they are taken via DHCP and you can overwrite them using network configuration tool but connecting to VPN can also change them and I do want to see the current list in the console.

How can I list them?

Best Answer

Open the terminal and enter the following command:

networksetup -getsearchdomains <networkservice>

Network service refers to the interface you are using (Wi-Fi, Ethernet, etc.). You can get a list of all interfaces by running the following command:

networksetup -listallhardwareports

Once you find the name of the hardware port, use that name in place of in the first command. For example, I generally use Wi-Fi so when I run the command it looks like this:

networksetup -getsearchdomains Wi-Fi