We want to develop websites or other internet services on our OSX computer. It’s convenient to point wildcard DNS for a whole (imaginary) top level domain to localhost, so we can invent as many domains as we want without having to edit any config files or do any work.

I used Homebrew to install dnsmasq:

% brew install dnsmasq

And then set up the config file:

cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
vi /usr/local/etc/dnsmasq.conf

To the end of that file I simply added:


Which tells dnsmasq to resolve any hostname ending in .dev to (localhost).

Now we need to tell the OS to start dnsmasq automatically. Again, brew will do all the hard work for us:

sudo brew services start dnsmasq

Let’s test to see if it’s working:

dig foo.dev @
; <<>> DiG 9.8.3-P1 <<>> foo.dev @
;; global options: +cmd
;; Got answer:
;; ->>HEADER< ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;foo.dev. IN A
foo.dev. 0 IN A

We asked the resolver running @ (dnsmasq) the address for “foo.dev” and it returned “” which is just what we want.

Now we need to get OSX to use that resolver for DNS lookups on the .dev TLD. OSX makes this pretty easy:

sudo mkdir -p /etc/resolver
sudo vi /etc/resolver/dev

And insert a line in that file just like you might in /etc/resolv.conf:


That’s it. Anything ending with .dev will point to localhost. So our next step is to run a server there.

2 thoughts on “Using dnsmasq on OSX 10.12 (Sierra) for local dev domain wildcards

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>