Cannot make outbound HTTP Requests from vagrant VM

前端 未结 1 971
臣服心动
臣服心动 2021-02-14 08:21

I am unable to connect to the internet from within a Vagrant virtual machine I have set up.

For example, at the root, when I type:

curl http://google.com         


        
相关标签:
1条回答
  • 2021-02-14 08:52

    This looks like a DNS configuration issue. Do a nslookup google.com and see what the result is.

    Try to add the following block in your Vagrantfile, set --natdnshostresolver1 to on so as to force the VirtualBox NAT engine to intercept DNS requests and forward them to host's resolver

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

    BTW: Without vagrant reload, you can directly look into the /etc/resolv.conf inside the VM, can manually set it to the DNS server of your network, most likely it'll work fine.

    0 讨论(0)
提交回复
热议问题