VirtualBox:从 ​​Windows 到 Ubuntu 的 NAT 端口转发不起作用

VirtualBox:从 ​​Windows 到 Ubuntu 的 NAT 端口转发不起作用

使用 NAT 时,我无法将 Windows 10 主机的端口转发设置为 Ubuntu 19 客户机。

我为 Ubuntu VM 添加了一条规则:

$ VBoxManage modifyvm "Ubuntu 19" --natpf1 ",tcp,,8081,,8081"

在 Ubuntu 上我使用 netcat 设置服务器:

$ nc -l 0.0.0.0 8081 -vvv
Listening on [] (family 2, port)

在 Windows 上我尝试发送一条消息但无法连接到访客:

$ telnet localhost 8081
Trying 127.0.0.1...

但是,当我尝试从 Ubuntu 向 Ubuntu 发送消息时,它连接成功:

$ telnet localhost 8081
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
haha 

我可以在以下位置看到相同的消息netcat

Connection from localhost 51766 received!
haha

我究竟做错了什么?

编辑#1

# ifconfig -a
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:42:bc:ef:27  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s3: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 08:00:27:28:b4:73  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1306  bytes 94378 (94.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1306  bytes 94378 (94.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

相关内容