Vagrant / VirtualBox DNS not working

Rudolf Vavruch asked:

I am running a fresh install of Linux Mint Nadia (14). I am following the instructions on Vagrant Getting Started but have gotten stuck on the Provisioning. It seems the Vagrant box cannot connect outside and so I can’t install anything using either Chef or Puppet.

In the basic Vagrant resolve.conf contains nameserver But with that set I can’t ping

If I change it to then I can ping but it does not stay set, and after a reboot it changes back to – so provisioning fails again.

Ideally I would like for to work on my setup. Failing that I would like a way to permanently change resolv.conf so that I can do provisioning.

My answer:

You can work around this issue in one of two ways, both of which are in the VirtualBox manual:

Enabling DNS proxy in NAT mode

The NAT engine by default offers the same DNS servers to the guest
that are configured on the host. In some scenarios, it can be
desirable to hide the DNS server IPs from the guest, for example when
this information can change on the host due to expiring DHCP leases.
In this case, you can tell the NAT engine to act as DNS proxy using
the following command:

VBoxManage modifyvm "VM name" --natdnsproxy1 on

Using the host’s resolver as a DNS proxy in NAT mode

For resolving network names, the DHCP server of the NAT engine offers
a list of registered DNS servers of the host. If for some reason you
need to hide this DNS server list and use the host’s resolver
settings, thereby forcing the VirtualBox NAT engine to intercept DNS
requests and forward them to host’s resolver, use the following

VBoxManage modifyvm "VM name" --natdnshostresolver1 on

Note that this setting is similar to the DNS proxy mode, however
whereas the proxy mode just forwards DNS requests to the appropriate
servers, the resolver mode will interpret the DNS requests and use the
host’s DNS API to query the information and return it to the guest.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.