Skip to content

Instantly share code, notes, and snippets.

Forked from ogrrd/dnsmasq OS
Last active March 16, 2016 09:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save spro/e56b7b6ce7c0af1aba8e to your computer and use it in GitHub Desktop.
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.dev domains, e.g., and so on, without having to add to your hosts file each time.



brew install dnsmasq


Setup *.dev

echo 'address=/.dev/' > $(brew --prefix)/etc/dnsmasq.conf


Work after reboot

sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons

Get it going right now

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

Add to resolvers

Create resolver directory

sudo mkdir -v /etc/resolver

Add your nameserver to resolvers

sudo bash -c 'echo "nameserver" > /etc/resolver/dev'

Add local DNS to search order in System Preferences

System Preferences > Network > Wi-Fi (or whatever you use) > Advanced... > DNS > add to top of the list.


That's it! You can run scutil --dns to show all of your current resolvers, and you should see that all requests for a domain ending in .dev will go to the DNS server at

Copy link

I think you can now also do sudo brew services start dnsmasq instead of sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

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