0

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?

5
  • 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, 2013 at 13:03
  • @Paul: Using Google DNS: 8.8.8.8 and 8.8.4.4. 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. Feb 17, 2013 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, 2013 at 21:07
  • 1
    What happens if you do a "traceroute -n 74.125.235.146" ? This will tell us if you have a problem with outbound Internet connectivity or the DNS service.
    – davidgo
    Feb 17, 2013 at 22:01
  • traceroute -n runs clean to completion. But traceroute to another ping-able (!) IP dies. @Paul: IP of guest is 10.0.2.15. Ping from host to guest fails. tcpdump on host as suggested fails ("no suitable device found"). Thanks for all the ideas. Keep 'em coming! ;-) Feb 18, 2013 at 5:31

1 Answer 1

3

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"]
end

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

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

You must log in to answer this question.

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