Skip to content

Instantly share code, notes, and snippets.

@erutan
Created January 10, 2013 21:38
Show Gist options
  • Save erutan/4506028 to your computer and use it in GitHub Desktop.
Save erutan/4506028 to your computer and use it in GitHub Desktop.

Alternate Wildcard DNS

dnsmasq will redirect *.dev requests to localhost for Apache to process.

Install dnsmasq via Homebrew:

brew install dnsmasq

Follow Homebrew's post install instructions, currently:

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

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

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

Open up /usr/local/etc/dnsmasq.conf

Add the following two lines to the bottom of the file:

address=/dev/127.0.0.1
listen-address=127.0.0.1

Open up /etc/resolv.conf - we'll need to check dnsmasq running on localhost first, then check external DNS servers for everything else. The following config is set to look for OpenDNS then fallback to Google.

nameserver 127.0.0.1
nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver 8.8.8.8

NOTE: may need to make these changes in system preferences > network > advanced > DNS to stick.

Now restart dnsmasq

sudo launchctl stop homebrew.mxcl.dnsmasq && sudo launchctl start homebrew.mxcl.dnsmasq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment