Posted in

Setup local DNS resolver on macOS

Instructions on how to install PowerDNS Recursor on macOS.

These commands need to be run from the Terminal.

Installation

Install Homebrew

 
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install PowerDNS recursor

 
brew install pdnsrec

Download and install the boot script from this Gist

 
sudo curl -so /Library/LaunchDaemons/homebrew.mxcl.pdnsrec.plist 'https://gist.githubusercontent.com/kometchtech/1cda9953aa51c1498183/raw/d85a7b283efef3c605e32d28a8f3ed07a41a2f1b/homebrew.mxcl.pdnsrec.plist' \
&& sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.pdnsrec.plist

Install boot script

 
sudo launchctl bootstrap system /Library/LaunchDaemons/homebrew.mxcl.pdnsrec.plist

Start the recursor on boot

 
sudo launchctl enable system/homebrew.mxcl.pdnsrec

And start it right now. No need to reboot your Mac.

 
sudo launchctl kickstart system/homebrew.mxcl.pdnsrec

Configuration

Security setting to enable strict DNSSEC validation.

 
cd /usr/local/etc/powerdns \
&& cp -n recursor.yml-dist recursor.yml \
&& sed -i '' -E 's/^#[[:blank:]]*dnssec:$/dnssec:/' recursor.yml \
&& sed -i '' -E 's/^# *validation: process$/  validation: validate/' recursor.yml

Go to System Preferences > Network and select your interface. Then go to Advanced > DNS tab and click the + to add a DNS server. Enter 127.0.0.1

You can further customize the resolver by editing the config file at /usr/local/etc/powerdns/recursor.conf

Reload config

When you’re done you need to restart the process like this:

 
sudo launchctl kickstart -k system/homebrew.mxcl.pdnsrec

Clearing the cache

To clear the local cache run:

 
sudo rec_control wipe-cache

or to clear only one domain zone:

 
sudo rec_control wipe-cache domain.name

Leave a Reply

Your email address will not be published. Required fields are marked *