DNS resolution from guest to host

Discussions about using Linux guests in VirtualBox.
Post Reply
thechrisroberts
Posts: 2
Joined: 21. Apr 2016, 14:01

DNS resolution from guest to host

Post by thechrisroberts »

First, this isn't a question about how to resolve specific hosts to my vm. I know about /etc/hosts. This is a little more complicated.

I'm setting up a vagrant box to be used for development, an in-house replacement for MAMP. I've got one version of the box up and running well but it's currently OS X only. Looking for ways to make it more OS agnostic.

With my vagrant box, one thing I've done is removed the need to edit /etc/hosts. For our development, we pretty much always use the .dev TLD for development. As part of my startup script, I create /etc/resolver/dev and give it a nameserver setting pointing to the ip of my vm. Within the vm, I'm using dnsmasq to resolve all .dev domains to itself. This solution works well - dev sites go to the vm, users don't have to touch their local /etc/hosts, and my startup script also doesn't have to touch /etc/hosts (thus not potentially conflicting with changes the user does want to make).

I could do something similar with Linux (though not quite as straightforward as with OS X), but I'm not sure how to accomplish something like this in Windows.

I'm wondering if there's any way to get VirtualBox itself to act as a resolver on the host machine - that is, is there a way I can configure VirtualBox to do what I've done via /etc/resolver/dev? That would simplify my script while increasing cross platform availability.

I've looked around a bit (particularly digging through chapter 9 of the online manual) so I think the answer is no, there isn't a way to do this, if for no other reason than VirtualBox doesn't appear to be doing anything to handle dns resolution for the host, but I thought I'd ask on here.
Post Reply