Per Domain DNS Servers in MacOS

MacOS has a nice facility as part of its DNS resolver that allows you to have a per-domain set of DNS servers. This is especially useful when using VPN services where you still need to use your local resolvers as well as the remote resolvers. Unfortunately, there is nowhere in the GUI to do this, nor any obvious indicator that it is even there.

To use it, you will need to be root for the operations (i.e. run sudo -i to get a root shell).

mkdir /etc/resolver 

This directory does not exist by default. Once you have created it, you just add files into this directory in the same form as the classic /etc/resolv.conf, and would be named as the domain you want to route the DNS requests for. So if you wanted to point requests for hosts in, you would create the file /etc/resolver/ and in it you would put:


This will tell the MacOS resolver that all requests for hosts in the domain will point to DNS servers and rather than the default DNS servers given by DHCP or manually set in the GUI.

If you need to stop the DNS routing, then just remove the file(s) you created in /etc/resolver.

Leave a Comment