25

I have a Debian image setup on Virtualbox that uses the default NAT to access the internet. It was working fine before I upgraded to 12.10. After I upgraded the DNS lookups no longer work. I still can access ip addresses, but this is not a nice solution.

2

6 Answers 6

22

In addition to VBoxManage modifyvm "name" --natdnsproxy1 on, I also had to run VBoxManage modifyvm "name" --natdnshostresolver1 on on each of my VMs to get DNS working. I found that tip on this page.

5
  • Sweet, found it somewhere else and it worked for me... then saw this hit a little further down the search results so had to vote it up.
    – El Yobo
    Jan 12, 2013 at 11:40
  • 1
    Only "--natdnshostresolver1 on" should actually be necessary, not "--natdnsproxy1 on".
    – Pi Delport
    Mar 1, 2013 at 10:30
  • This did not work. Both of them. I am using this batch script (gist.github.com/kapitanluffy/61316b4595f3b63ccf41) and does not work.The adapter type is PCnet-PCI II Mar 24, 2013 at 20:37
  • I have set the resolv.conf to 8.8.8.8 and it worked. Do I still need to issue the modifyvm commands? Mar 24, 2013 at 20:44
  • Thanks, this solved the mysterious problem for me, too. To make this solution move up in the Google results, it should be noted that the problem is related to VirtualBox 4.1.18 (this is what I searched for).
    – Andre
    Apr 19, 2013 at 18:50
11

Got it

VBoxManage modifyvm "VM name" --natdnsproxy1 on

Virtual box has a DHCP server for the NAT engine. Which has a list of registered DNS servers. The above command hides 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

3
  • Do you know if there is a way to set this as the default, or change this in the GUI? I'm having the same issue, but typing that for all my VMs seems like a lot of work I'd rather avoid. Thanks.
    – dobey
    Oct 23, 2012 at 3:14
  • 1
    @dobey I'm petty sure you cant do this in the GUI. If you have a lot I would probably write a script. You can get list of your VMs names with VBoxManage list vms Then just iterate through that list
    – null_radix
    Oct 23, 2012 at 23:51
  • That's unfortunate if so. There should be a way to set it as the default. Perhaps the package needs patched or something then. :-/
    – dobey
    Oct 24, 2012 at 0:26
3

Apparently you need to upgrade VritualBox to 4.2, otherwise it won't work

2
  • 1
    Is this your personal experience? Did you find this documented anywhere?
    – Lord Loh.
    Nov 2, 2012 at 20:21
  • 1
    I can confirm (from personal experience) that upgrading to 4.2 seems to fix the issue... my box wasn't able to connect to the internet, after the update it magically works.
    – Ben
    Dec 17, 2012 at 11:47
1

The --natdnsproxy1 on didn't work for me. :(

But I was able to go into the virtual machine and set my DNS server by hand, and that worked.

My host machine is resolving to the loopback device. Not sure how or why /etc/resolv.conf got set to the loopback. My host network connection has a static DNS server configured, that is NOT set to the loopback device.

But everything is resolving fine on my host machine, via the loopback. Odd.

2
  • Oops, just realized it isn't the loopback, it is instead; Received 43 bytes from 127.0.1.1#53 in 67 ms Which seems to be explained here; debian.org/doc/manuals/debian-reference/…
    – Ted Parvu
    Oct 24, 2012 at 21:23
  • 1
    It is the loopback device, but it is not localhost. The DNS entry pointing to 127.0.1.1 though, is a result of Ubuntu using a local caching nameserver, which is running on that interface.
    – dobey
    Oct 24, 2012 at 21:37
0

I had a similar problem with DNS stop working. It happened using virtual box version 5.02r102096 running ubuntu server as guest on windows 10 64 bit as host. The problem occurred after I first activated port forwarding.

Apparently until you activate port forwarding for the NAT it automatically enables port 53 forwarding. I enabled UDP and TCP forwarding on port 53 and DNS started working again. It did not work with only UDP forwarded.

I am a little concerned that my host may no longer receive and process port 53 and will fail future DNS lookup as a result but have not tried it. If this is correct then we probably need to also forward some of the other ports like network Time.

I suspect this is a bug in VirtualBox where it should automatically enable forwarding / sharing some of these common ports unless you explicitly disable them.

I also modified the network interfaces in linux to include the name servers. /etc/network/interfaces with the line dns-nameservers xx.xx.xx.xx but this had no effect on the problem until port 53 was forwarded.

Note: I tried to post two pictures to make it more clear but the blog required a reputation of 10 so I couldn't. You can contact me via bayesanalytic.com thanks Joe E.

0
-1

FYI I have grabbed the most recent version of VirtualBox (4.2.16) and it fixes this issue. No CLI commands are necessary to have working DNS on a NAT network.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .