Brew install dnsmasq in macOS Sierra

Oct 17, 2016 · 1 min read

Install Brew

Visit the web

or Paste that at a Terminal prompt.

/usr/bin/ruby -e "$(curl -fsSL"

Install DNSMasq


brew install dnsmasq

Create config directory

mkdir -pv $(brew --prefix)/etc/

Setup *.dev

echo 'address=/.dev/' > $(brew --prefix)/etc/dnsmasq.conf
echo 'no-resolv' > $(brew --prefix)/etc/dnsmasq.conf
echo 'strict-order' > $(brew --prefix)/etc/dnsmasq.conf
echo 'server=' > $(brew --prefix)/etc/dnsmasq.conf
echo 'listen-address=,192.168.x.x' > $(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.

Reload dnsmasq service

$ sudo launchctl unload homebrew.mxcl.dnsmasq.plist && sudo launchctl load homebrew.mxcl.dnsmasq.plist

Start dnsmasq service

sudo launchctl start homebrew.mxcl.dnsmasq

Stop dnsmasq service

sudo launchctl stop homebrew.mxcl.dnsmasq

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade