我从Vagrant运行Ubuntu 16.04(来宾主机名为silver)。但我无法访问客人打开的端口(但流浪转发效果很好)。我启动php-server进行测试:
php -S 0.0.0.0:8088
vagrant@silver:~$ netstat -atn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 10.0.2.15:22 10.0.2.2:50376 ESTABLISHED
tcp 0 0 10.0.2.15:22 10.0.2.2:55996 ESTABLISHED
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::25 :::* LISTEN
但是无法从主机评估来宾端口8088。
从主持人扫描访客:
nmap -v -sT silver
Starting Nmap 7.00 ( https://nmap.org )
Initiating Ping Scan at 20:18
Scanning silver (192.168.33.1) [2 ports]
Completed Ping Scan at 20:18, 0.00s elapsed (1 total hosts)
Initiating Connect Scan at 20:18
Scanning silver (192.168.33.1) [1000 ports]
Discovered open port 111/tcp on 192.168.33.1
Discovered open port 1023/tcp on 192.168.33.1
Discovered open port 1021/tcp on 192.168.33.1
Discovered open port 999/tcp on 192.168.33.1
Discovered open port 8000/tcp on 192.168.33.1
Discovered open port 2049/tcp on 192.168.33.1
Discovered open port 8001/tcp on 192.168.33.1
Completed Connect Scan at 20:18, 3.13s elapsed (1000 total ports)
Nmap scan report for silver (192.168.33.1)
Host is up (0.0030s latency).
Not shown: 498 closed ports, 495 filtered ports
PORT STATE SERVICE
111/tcp open rpcbind
999/tcp open garcon
1021/tcp open exp1
1023/tcp open netvenuechat
2049/tcp open nfs
8000/tcp open http-alt
8001/tcp open vcom-tunnel
我也禁用了ufw:
vagrant@silver:~$ sudo ufw status
Status: inactive
Vagrant端口转发效果很好。我的Vagrantfile:
...
config.vm.box = "bento/ubuntu-16.04"
config.vm.network "forwarded_port", guest: 80, host: 8001
config.vm.hostname = "silver"
config.vm.network "private_network", ip: "192.168.33.1"
...
我无法访问任何端口,80,3600等。但可以访问8001 - 来自流浪者转发。