Skip to content

Instantly share code, notes, and snippets.

@kstefanini
Forked from r10r/enable_dnsmasq_on_osx.sh
Last active December 30, 2015 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kstefanini/7789268 to your computer and use it in GitHub Desktop.
Save kstefanini/7789268 to your computer and use it in GitHub Desktop.
# ----------------------
# installing dnsmasq and enable daemon
# ----------------------
brew install dnsmasq
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
# ----------------------
# adding resolver for local domain
# ----------------------
[ -d /etc/resolver ] || sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/local'
# ----------------------
# configuring dnsmasq
# ----------------------
cat > $(brew --prefix)/etc/dnsmasq.conf <<-EOF
listen-address=127.0.0.1
dhcp-range=192.168.56.50,192.168.56.60
domain=local
# keep nameserver order of resolv.conf
strict-order
EOF
# ----------------------
# launching dnsmasq
# ----------------------
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
# ----------------------
# relaunch 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