Skip to content

Instantly share code, notes, and snippets.

@drye
Forked from r10r/enable_dnsmasq_on_osx.sh
Last active September 6, 2021 09:23
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save drye/5387341 to your computer and use it in GitHub Desktop.
Save drye/5387341 to your computer and use it in GitHub Desktop.
# bash <(curl -s https://gist.github.com/drye/5387341/raw/ec72cddfe43ec3d39c91a3c118cb68ab14a049f8/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/vbox'
# ----------------------
# configuring dnsmasq
# ----------------------
sudo mkdir -p $(brew --prefix)/etc/
cat > $(brew --prefix)/etc/dnsmasq.conf <<-EOF
listen-address=127.0.0.1
address=/.vbox/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
@simongcc
Copy link

I have tried this script and it works by adding .vbox to the Mac. Is this DNSMasq in the Mac can let other devices to access like mobile phone? What additional setup is required?

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