I have a Vagrant-provisioned CentOS guest on an Ubuntu host. Internet access from host is absolutely fine. But Internet access from guest often fails unless host is using VPN.

For example:

Host using standard network adapter, no VPN:

$ curl https://packagist.org/packages.json
curl: (6) Couldn't resolve host 'packagist.org'

Host using VPN:

$ curl https://packagist.org/packages.json
{ successful-json-payload }

Guest networking is NAT. VirtualBox GUI showing the correct host adapter.

I live in Thailand and VPN is US-based. Ideas?

  • 2
    The error is telling you that DNS is not working. What name servers have you set in the guest, and can you ping them? – Paul Feb 17 '13 at 13:03
  • @Paul: Using Google DNS: and Yep, can ping them from the guest. But attempting to curl (from the guest) the standard assortment of reliable sites fails with curl: (6) Couldn't resolve host. And still, if I connect the host to my VPN, those curls all sail through smoothly. – David Weinraub Feb 17 '13 at 16:03
  • 1
    Strange, the dns must be getting bloked, or failing to NAT. Your question says "often fails", does that means it works without VPN sometimes? How about doing a tcpdump host <guest ip> and port 53 on the host to see if the DNS queries are making it out ok. – Paul Feb 17 '13 at 21:07
  • 1
    What happens if you do a "traceroute -n" ? This will tell us if you have a problem with outbound Internet connectivity or the DNS service. – davidgo Feb 17 '13 at 22:01
  • traceroute -n runs clean to completion. But traceroute to another ping-able (!) IP dies. @Paul: IP of guest is Ping from host to guest fails. tcpdump on host as suggested fails ("no suitable device found"). Thanks for all the ideas. Keep 'em coming! ;-) – David Weinraub Feb 18 '13 at 5:31

You might want to configure your vagrant according to the snippet below, might have something to do with it. It was driving me nuts too!

Vagrant::Config.run do |config|
  # ...

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

source : https://gist.github.com/mitchellh/1277049

  • That looks like an interesting idea. I'll try it out and get back to you. Thanks! ;-) – David Weinraub Mar 21 '13 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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