osx – Vagrant将不会转发80端口

前端之家收集整理的这篇文章主要介绍了osx – Vagrant将不会转发80端口前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有端口转发设置为流氓
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,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@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)

盒子是来自流浪者,centos 6.3与厨师的形象.

那么为什么我无法从本地机器连接到80端口?

我不认为你可以转发到主机端口1024,除非您在主机上以root身份运行VirtualBox.

作为NAT模式的限制,VirtualBox Manual证明了这一点:

Forwarding host ports < 1024 impossible:

On Unix-based hosts (e.g. Linux,Solaris,Mac OS X) it is not possible to bind to ports below 1024 from applications that are not run by root. As a result,if you try to configure such a port forwarding,the VM will refuse to start.

这些限制通常不会影响标准网络的使用.但NAT的存在也有可能干扰正常工作的协议的微妙效果.一个例子是NFS,其中服务器通常被配置为拒绝来自非特权端口的连接(即端口不低于1024).

原文链接:https://www.f2er.com/centos/374089.html

猜你在找的CentOS相关文章