Skip to content

Instantly share code, notes, and snippets.

@danmactough
Last active August 18, 2016 06:01
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danmactough/11188040 to your computer and use it in GitHub Desktop.
Save danmactough/11188040 to your computer and use it in GitHub Desktop.

Install Dnsmasq on OSX

This will allow any url having the non-existant TLD .dev to resolve to your locale machine.

Install dnsmasq and run as a service

$ brew update
$ brew install dnsmasq
# Follow the instructions...
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

Configure dnsmasq

Somewhere in /usr/local/etc/dnsmasq.conf add the following:

address=/dev/127.0.0.1

Dnsmasq should automatically reload the configuration when it changes.

Configure OSX to use dnsmasq

  • make sure you have a directory for additional dns resolvers
$ sudo mkdir -p /etc/resolver
  • create the dev resolver
$ sudo sh -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'

OSX should automatically load the resolver.

Test

ping this.is.a.test.server.dev
@danmactough
Copy link
Author

Sometimes after you install dnsmasq, you need to reboot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment