Install DNSmasq locally on Mac OS X via Homebrew

This post describes hot to use dnsmasq as a local DNS server for faster caching and to resolve domain names in your private address space.

Installing dnsmasq

Installing dnsmasq is easy when you have Homebrew installed on your Mac:

brew update && brew install dnsmasq

And follow Homebrew's hints on how to activate dnsmasq:

# copy example configuration file:
cp /usr/local/Cellar/dnsmasq/2.57/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
# To load dnsmasq automatically on startup:
sudo cp /usr/local/Cellar/dnsmasq/2.57/ /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/

Configuring dnsmasq

OK, let's edit the dnsmasq configuration file /usr/local/etc/dnsmasq.conf now.

# Change this line if you want dns to get its upstream servers from somewhere other that `/etc/resolv.conf`:

You also have to uncomment the line that says listen-address= .

Then save the following as /etc/resolv.dnsmasq.conf:

# Philipp's custom nameserver selection
# OpenDNS IPv6:
nameserver 2620:0:ccd::2
# Google:
# OpenDNS IPv6:
nameserver 2620:0:ccc::2
# OpenDNS:

(Re)Starting dnsmasq (The sudo launchctl load -w [...] command must have been run beforehand):

sudo launchctl stop && sudo launchctl start

Tell OS X to use dnsmasq

Now, edit /etc/resolv.conf to have ONLY the following line in it:


Set the DNS settings in the network settings' system preferences pane to and ::1 to change this permanently.