Skip to content

Instantly share code, notes, and snippets.

@whitegfx
Forked from drye/enable_dnsmasq_on_osx.sh
Last active August 21, 2018 10:14
Show Gist options
  • Save whitegfx/18997ea4114854f2fd34755312154726 to your computer and use it in GitHub Desktop.
Save whitegfx/18997ea4114854f2fd34755312154726 to your computer and use it in GitHub Desktop.
# bash <(curl -s https://gist.githubusercontent.com/whitegfx/18997ea4114854f2fd34755312154726/raw/810d02408c6f1bf4b51239e103d016f5b14d404e/enable_dnsmasq_on_osx.sh)
# ----------------------
# installing dnsmasq and enable daemon
# ----------------------
brew install dnsmasq
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
# ----------------------
# adding resolver for vbox domain
# ----------------------
[ -d /etc/resolver ] || sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/loc'
# ----------------------
# configuring dnsmasq
# ----------------------
sudo mkdir -p $(brew --prefix)/etc/
cat > $(brew --prefix)/etc/dnsmasq.conf <<-EOF
listen-address=127.0.0.1
address=/.loc/127.0.0.1
# keep nameserver order of resolv.conf
strict-order
EOF
# ----------------------
# launching dnsmasq
# ----------------------
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