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 18.104.22.168 address=/.dev/22.214.171.124
- 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 126.96.36.199 ...
I’m also considering setting up an SSH tunnel from my VPS to my Laptop, like showoff.io, but DIY.