Using dnsmasq with VirtualBox and OS X
When working with various virtual machines and browsers, your hosts file can start to look a little over subscribed, and rather difficult to manage.
One of my colleagues mentioned dnsmasq – and he implemented it on his host machine to resolve names for various VM’s.
I didn’t really want to install it on the host, so went for having it on the VM, so that each one could resolve it’s own list of domains. In the instructions, I’m making the assumption that the VM has a DHCP provided IP from the host only network within VirtualBox, and it’s host name (the name I’m connecting to from the host machine is devbox). Here’s what I did.
1. Install dnsmasq on Debian with apt
sudo apt-get install dnsmasq
2. Open up /ect/dnsmasq.conf and add:
address=/devbox/192.168.56.101
3. Restart dnsmasq
sudo /etc/init.d/dnsmasq restart
4. Then in your host machine’s /etc/hosts file add:
devbox 192.168.56.101
5. If you’re using OS X, create the folder /etc/resolver
sudo mkdir /etc/resolver
6. Create a named entry for your box
Mine’s called devbox, I’d do:
echo "nameserver 192.168.56.101" > /etc/resolver/devbox
And that should now work nicely – somesubdomain.devbox for example will resolve to that VM.
2 Responses to Using dnsmasq with VirtualBox and OS X
Leave a Reply Cancel reply
Pages






I recently had to do the same thing for OS X Lion given its new, stupid, DNS resolution order:
http://www.justincarmony.com/blog/2011/07/27/mac-os-x-lion-etc-hosts-bugs-and-dns-resolution/
Thanks for the link and comment Ben!