Skip to main content
  1. posts/

macOS: Using Custom DNS Resolvers

·272 words·2 mins·
Christian Mohn
macOS DNS
Author
Christian Mohn
IT veteran, podcaster, author, and blogger from Bergen, Norway.

Some times there is a need to use custom DNS servers for some domains, in my case specifically for access to the new lab environment we are building at work (more on that later, this is one beefy lab!)

One way of doing this, is adding custom DNS servers to /etc/resolv.conf but in macOS you really shouldn’t be editing that file manually, as it often gets overwritten or otherwise edited by VPN clients and such.

Thankfully, there is a better way to create persistent and manageable custom domain specific DNS settings.

  1. Make a new folder called /etc/resolver/
  2. Inside that folder, create a new file with the name of the domain you want custom DNS settings for, in this case myhugelab.local
  3. Edit that file, and add your custom domain, search path and nameservers. My example file looks like this
domain myhugelab.local
search myhugelab.local
nameserver 10.0.0.53
nameserver 10.0.0.54
  1. Save the file, and run sudo killall -HUP mDNSResponder in your terminal of choice to force a DNS refresh
  2. Verify that the new DNS settings are in place by running scutil --dns and looking at the output for the entries added in step 3.
resolver #8
  domain   : myhugelab.local
  search domain[0] : myhugelab.local
  nameserver[0] : 10.0.0.53
  nameserver[1] : 10.0.0.54
  1. Check that name resolution works!

This way I can redirect host name resolution to the lab DNS servers, without having to do anything but connect to that network first. Doing this with /etc/resolver/domainname files, is a lot cleaner than other methods, requires less work and is much easier to keep track of. I’d call that a win every day! And remember, it’s always DNS.

DNS Haiku

Unless it’s NTP.

Related

macOS: Using and creating Multi-Output Sound Devices
·419 words·2 mins
Christian Mohn
macOS
macOS: Catalina Chrome Self-signed Certificate Issues
·474 words·3 mins
Christian Mohn
macOS TLS Security Certificates VMware vSphere Chrome
My Pi-Hole Setup
·594 words·3 mins
Christian Mohn
Pi-Hole DNS Linux Ubuntu Blogtober2018