How to get VirtualBox VMs to use host's DNS?

To enable DNS Proxy Mode using the host's resolver, run the following command:

VBoxManage modifyvm "<VM name>" --natdnshostresolver1 on

As a result, guest OS DNS requests will be intercepted and resolved using host DNS API, rather than having guest OS connect to external DNS servers as with --natdnsproxy1 on.

You can get the name of the VM by running VBoxManage list runningvms.


Yes it is possible. There are many modes available in VirtualBox to establish networking between the guest and the host. Rather than using the NAT mode (which is default), you can use the bridge-mode in which your guest machine can be treated as entirely separate entity on your network. So, not only your host, but any other machine (such as your DNS server) will see your guest as a separate machine.

Once you setup the bridge-mode, just go to your ubuntu guest and get it to use your company's DNS server name or ip. Read this tutorial for more info: http://prahladyeri.wordpress.com/2012/08/02/how-to-setup-a-virtual-lan-on-your-machine-using-oracle-virtualbox/


This was a top Google result, so I wanted to clarify for others. Josiah's solution worked for me with the addition of adding the line:

hosts: files dns to /etc/nsswitch.conf

As others pointed out, the original solution does not work above Ubuntu 16.04. My guest VM is Ubuntu 16.04.

Reference Creating Linux Server