Create local wildcard DNS

Some time ago I posted a guide to setup a zero config webserver on mac OSX. As it turns out this will stop working once your OSX version is high enough. Here's a new way that will be easier to setup.

Prerequirements

All you need is Homebrew.

Installation

$ brew update
$ brew install dnsmasq

To configure dnsmasq, copy the example configuration to /usr/local/etc/dnsmasq.conf and edit to taste.

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

To create a *.dev wildcard add the following line:

 address=/dev/127.0.0.1

To have launchd start dnsmasq at startup:

$ sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons

Then to load dnsmasq now:

$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

Network settings

Now that your nameserver is set up, you will need to tell the system to use it.

Using resolver

$ sudo mkdir -p /etc/resolver
$ sudo sh -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'

Using settings

Open your system preferences, and click network, then advanced button. If needed add 127.0.0.1 to your server list with the + on left and drag it to the top of the list. Make sure you have some fallback servers, like those from you ISP or others like opendns.


Fork me on GitHub