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:
3. Restart dnsmasq
sudo /etc/init.d/dnsmasq restart
4. Then in your host machine’s /etc/hosts file add:
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.