18

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?

3
  • 1
    There was an issue with my server client getting a DNS. Using google DNS, changed in /etc/resolv.conf and added to /etc/network/interfaces solved the problem. Jan 9, 2013 at 16:27
  • Can I ask you which tutorial you are using? Just a guess: is it gettingstartedwithdjango? If so, I will contact the author to refer to the present problem. If not, I will delete this comment.
    – don.joey
    Mar 13, 2013 at 10:55
  • I'm not using the tutorial you mentioned. Found the solution using common sense yet bayoffire solution is much better, also it's known bug as he mentioned so I do belive it'll be fixed in future release. Mar 19, 2013 at 13:05

4 Answers 4

30

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

3
  • Good to know it is a known bug, even though I didn't managed to find something about it myself. The workaround I've mentioned in my comment above solved it for me though. At least other peoples with same error will have two different ways to solve this issue. Thank you. Jan 12, 2013 at 9:24
  • Even more about this issue. Your solution will be more appropriate since DNS configuration made manually (as suggested by me above) will be deleted every time I start the VM Jan 12, 2013 at 9:26
  • 1
    See this answer for a solution on newer versions of Vagrant: askubuntu.com/a/296796/122097
    – Brad
    Oct 14, 2013 at 15:45
6

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/

1
  • this fixes the following error: Cannot add PPA: 'ppa:brightbox/ruby-ng'. Please check that the PPA name or format is correct. on Ubuntu 14 with vagrant 1.7.2 and virtualbox on macos.
    – nruth
    Feb 5, 2015 at 22:43
5

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
2

The (new) default Vagrantfile* contains a bunch of commented-out examples, one of which is as follows:

  # Assign this VM to a bridged network, allowing you to connect directly to a
  # network using the host's network device. This makes the VM appear as another
  # physical device on your network.
  # config.vm.network :bridged

Make sure you un-comment this line:

conig.vm.network :bridged

That will give your virtual machine access to the network/Internet.

* As of version 1.0.6. As of the time of this answer, the latest version in the repository is 1.0.3, it may not have all of the extra examples; in which case, you'll need to add that line of code.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.