Setting up a wildcard DNS domain on Mac OS X

By Bilpp Team

There are many ways to develop on a Mac, and many stack to choose from. One common and recurring need however is to access your local websites through a named domain, ie using Thankfully, there is a really simple way to do this using Dnsmasq as a local resolver.

Install Dnsmasq

This is straightforward with Homebrew:

brew install dnsmasq

# Create the etc dir if needed

mkdir -p /usr/local/etc

# Create a simple configuration

# This forces the .dev domain to respond with

# You can find more information in the default config file:

# /usr/local/opt/dnsmasq/dnsmasq.conf.example

echo “address=/.dev/” > /usr/local/etc/dnsmasq.conf

# Install the daemon startup file

sudo cp -fv /usr/local/opt/dnsmasq/*.plist \


# Start the daemon

sudo launchctl load \


Configure Mac OS X

All we need to do is tell the resolver to use Dnsmasq for .dev domains:

# man 5 resolver

sudo mkdir -p /etc/resolver

sudo sh -c ‘echo “nameserver” > /etc/resolver/dev’

You can now use any .dev domain and it will always resolve to

ping # this still works

# PING ( 56 data bytes

ping # you can use any domain

# PING ( 56 data bytes

ping # or subdomain

# PING ( 56 data bytes


This is very useful in particular for applications that use subdomains as account identifier: you can easily create new accounts on the fly, and never have to worry about your /etc/hosts file again.

Finally, you may also want to look at Pow (and powder). Pow will automatically start your Rails/Rack applications, and provides a port proxying feature for apps written in other languages. Definitely a great alternative.

That’s it for today.