php – 无法从流氓虚拟机发出出站HTTP请求

前端之家收集整理的这篇文章主要介绍了php – 无法从流氓虚拟机发出出站HTTP请求前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我无法从我设置的Vagrant虚拟机中连接到互联网.

例如,在根目录下,当我键入:

  1. curl http://google.com

它失败了消息:

  1. curl: (6) Couldn't resolve host 'google.com'

我不知道是否是防火墙设置,尽管据我所知,我还没有为端口80或其他端口创建任何防火墙规则.

这是我的Vagrantfile的相关部分.如果有任何其他信息,我可以提供,请让我知道在评论

  1. Vagrant.configure("2") do |config|
  2. # All Vagrant configuration is done here. The most common configuration
  3. # options are documented and commented below. For a complete reference,# please see the online documentation at vagrantup.com.
  4.  
  5.  
  6. # Let Vagrant manage the hostname at boot
  7. config.vm.hostname = "devBox"
  8.  
  9. # Create a forwarded port mapping which allows access to a specific port
  10. # within the machine from a port on the host machine. In the example below,# accessing "localhost:8080" will access port 80 on the guest machine.
  11. # config.vm.network :forwarded_port,guest: 80,host: 8080
  12.  
  13. # Create a private network,which allows host-only access to the machine
  14. # using a specific IP.
  15. config.vm.network :private_network,ip: "10.0.0.10"
  16.  
  17. # Create a public network,which generally matched to bridged network.
  18. # Bridged networks make the machine appear as another physical device on
  19. # your network.
  20. # config.vm.network :public_network
  21.  
  22. # Create a public network with a given hardware address. You can
  23. # configure your DHCP server (on your router) to assign a particular IP
  24. # address to the VM. Update your hosts file accordingly.
  25. # config.vm.network :public_network,mac: "0a00251010101"
  26.  
  27. # Share an additional folder to the guest VM. The first argument is
  28. # the path on the host to the actual folder. The second argument is
  29. # the path on the guest to mount the folder. And the optional third
  30. # argument is a set of non-required options.
  31. #config.vm.synced_folder "vagrant/logs","/logs",# owner: "root",group: "root"
  32.  
  33. # Base Box to use with VirtualBox provider
  34. config.vm.Box = "debian-7.0.0-amd64-base"
  35. config.vm.Box_url = "http:/mysite.com/debian-7.0.0-amd64-base.Box"
这看起来像DNS配置问题.做一个nslookup google.com,看看结果是什么.

尝试在您的Vagrantfile中添加以下块,将–natdnshostresolver1设置为on,以强制VirtualBox NAT引擎拦截DNS请求并将其转发到主机的解析器

  1. config.vm.provider :virtualBox do |vb|
  2.  
  3. vb.customize ["modifyvm",:id,"--natdnshostresolver1","on"]
  4.  
  5. end

BTW:没有vagrant重新加载,您可以直接查看VM中的/etc/resolv.conf,可以手动将其设置为网络的DNS服务器,很有可能会正常工作.

猜你在找的PHP相关文章