如何在 Vagrant 中启用互联网访问? [英] How to enable internet access inside Vagrant?

查看:28
本文介绍了如何在 Vagrant 中启用互联网访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我运行 curl google.com,我看不到输出,只有一个空白页.我的 Vagrantfile 包含:

If I run curl google.com, I can't see the output, only a blank page. My Vagrantfile contains:

Vagrant.configure("2") do |config|
  config.vm.box = "trumobi"
 #config.vm.box_url = "http://192.168.136.129/package.box"
  config.ssh.default.username = "trumobi"
  config.vm.network :public_network
  config.vm.network :forwarded_port, host: 8000, guest: 8000
end

推荐答案

如果您使用的是 Vagrant + VirtualBox + Ubuntu,您可能需要将以下块添加到您的 VagrantFile:

If you are using Vagrant + VirtualBox + Ubuntu, you might want to add the following block to your VagrantFile:

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

如果您使用的是 ubuntu,并且您认为您的防火墙是on,那么您可以通过以下方式关闭防火墙:

If you are using ubuntu, and you think your firewall is on, here's how you turn off the firewall:

sudo ufw disable

这篇关于如何在 Vagrant 中启用互联网访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆