Brew install dnsmasq in macOS Sierra

Naraku
Naraku
Oct 17, 2016 · 1 min read

Install Brew

Visit the web http://brew.sh/

or Paste that at a Terminal prompt.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install DNSMasq

Install

brew install dnsmasq

Create config directory

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

Setup *.dev

echo 'address=/.dev/127.0.0.1' > $(brew --prefix)/etc/dnsmasq.conf
echo 'no-resolv' > $(brew --prefix)/etc/dnsmasq.conf
echo 'strict-order' > $(brew --prefix)/etc/dnsmasq.conf
echo 'server=208.67.222.222#5353' > $(brew --prefix)/etc/dnsmasq.conf
echo 'listen-address=127.0.0.1,192.168.x.x' > $(brew --prefix)/etc/dnsmasq.conf

Autostart

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 127.0.0.1" > /etc/resolver/dev'

Add local DNS to search order in System Preferences

System Preferences > Network > Wi-Fi (or whatever you use) > Advanced… > DNS > add 127.0.0.1 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