If you’re a developer who frequently updates his hostfile to try out new sites or services locally, you might want to try dnsmasq.
I’m running OS X Mountain Lion. All development takes place in a couple of Vagrant-managed Virtualboxes running on 33.33.33.x.
I don’t like having to wait for sysadmins to get DNS stuff and its paperwork in place, so I just configure some rules in dnsmasq and point these domains to my virtual server.
To get started:
Install Homebrew (instructions found over there)
$ brew install dnsmasq
- Copy the plist file over:
$ sudo cp /usr/local/Cellar/dnsmasq/2.61/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons/
- Copy the example config over:
$ cp /usr/local/Cellar/dnsmasq/2.61/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
Add 127.0.0.1 as the first entry in OS X > System Preferences > Your connection > Advanced > DNS
Edit /usr/local/etc/dnsmasq.conf, adding some address= entries as you please:
# This entry redirects every domain ending in .dev to the Vagrant box on 220.127.116.11 address=/.dev/18.104.22.168
- Launch the dnsmasq daemon:
$ sudo launchctl start homebrew.mxcl.dnsmasq
- Flush your dns:
$ sudo dscacheutil -flushcache
- Test if it worked:
$ dig www.someproject.dev
- Should answer with:
... ;; ANSWER SECTION: www.someproject.dev. 0 IN A 22.214.171.124 ...
I’m also considering setting up an SSH tunnel from my VPS to my Laptop, like showoff.io, but DIY.