我为 vagrant 设置了端口转发
Vagrant.configure("2") do |config|
config.vm.box = "centOS"
config.vm.network :forwarded_port, guest: 80, host: 80
config.vm.network :forwarded_port, guest: 8443, host: 8443
config.vm.network :forwarded_port, guest: 8443, host: 9443
config.vm.network :forwarded_port, guest: 8445, host: 8445
config.vm.network :forwarded_port, guest: 8000, host: 8000
config.vm.hostname = "www.vagrant.com"
end
80 端口从我的 vagrant virtual box 中打开
[vagrant@www ~]$ nmap -sT 0.0.0.0 -p 80
Starting Nmap 5.51 ( http://nmap.org ) at 2013-07-02 22:25 UTC
Nmap scan report for 0.0.0.0
Host is up (0.000063s latency).
PORT STATE SERVICE
80/tcp open http
但它从我的主机关闭
Ben-Fischer:~ bfischer$ nmap -sT 0.0.0.0 -p 80
Starting Nmap 6.25 ( http://nmap.org ) at 2013-07-02 17:38 CDT
Nmap scan report for 0.0.0.0
Host is up (0.000086s latency).
PORT STATE SERVICE
80/tcp closed http
我的主机上没有其他东西在监听端口 80
Ben-Fischer:~ bfischer$ sudo lsof -n -i4TCP:80 | grep LISTEN
[no output]
iptables 关闭了,我的 mac 防火墙也关闭了
[vagrant@www ~]$ sudo service iptables stop
所有其他转发端口都可以正常工作(8443,9443,8445,8000)
该框是来自 vagrant,centOS 6.3 和厨师的图像。
那么......为什么我不能从我的本地机器连接到端口 80?