Skip to content

Instantly share code, notes, and snippets.

@r10r
Last active October 11, 2019 04:27
Show Gist options
  • Star 48 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save r10r/5108046 to your computer and use it in GitHub Desktop.
Save r10r/5108046 to your computer and use it in GitHub Desktop.
Installs and configures dnsmasq on osx (for local resolution of development machines e.g virtualbox). Cudos to Alan Ivey http://www.echoditto.com/blog/never-touch-your-local-etchosts-file-os-x-again
# ----------------------
# 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
# ----------------------
cat > $(brew --prefix)/etc/dnsmasq.conf <<-EOF
listen-address=192.168.56.1
listen-address=127.0.0.1
dhcp-range=192.168.56.50,192.168.56.60
domain=vbox,192.168.56.0/24,local
dhcp-leasefile=/var/lib/dnsmasq/dnsmasq.leases
# keep nameserver order of resolv.conf
strict-order
EOF
# ----------------------
# launching dnsmasq
# ----------------------
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
@brablc
Copy link

brablc commented Jun 3, 2013

It may be handy to add commands for restart:

sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq

@bfontaine
Copy link

What does IP 192.168.56.1 refers to?

@sodacrackers
Copy link

This line (#10) should be changed to a >> or it erases 500 lines of comments and useful options in the options file. echo "nameserver 127.0.0.1" >

@sodacrackers
Copy link

This part on setting up your folders and Apache to support the vhosts seems useful-- https://mallinson.ca/osx-web-development/

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