How do I fix name service for Vagrant client?

I am new to Ubuntu (having just installed Ubuntu 12.10) and want to start developing with it. So I have installed Vagrant, downloaded lucid64.box, initialized, started it up and accessed it via ssh.

To the test the Internet connection on my client I've done ping google.com and received unknown host: google.com. (Host got ping of course.)

Searching the web only got me to this solution which suggested to remove Vagrant and Virtual box, and re-install them, just make sure Vagrant installed first. I've tried this solution and I am still getting the same results.

What else can I try to get it to work?


I had the same issue with Ubuntu 12.10 and found a solution. Just add those lines to your Vagrantfile:

config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
config.vm.customize ["modifyvm", :id, "--natdnsproxy1", "on"]

For Vagrant 1.1+ you will need (thanks to farooqsadiq)

config.vm.provider "virtualbox" do |v| 
  v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end

It seems to be a known bug in VirtualBox on Ubuntu 12.10:

https://bugs.launchpad.net/ubuntu/+source/virtualbox/+bug/1048783

https://www.virtualbox.org/ticket/10864


For Vagrant 1.1+ you will need

config.vm.provider "virtualbox" do |v| 
  v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end

Tested on Vagrant 1.2.2

Found on Lyte's Blog http://lyte.id.au/tag/vagrant/


You can make the modifyvm trick work across all Vagrant VMs in one hit by putting a snippet in ~/.vagrant.d/Vagrantfile, e.g.:

Vagrant::Config.run do |config|
    config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end