【发布时间】:2017-11-25 15:23:58
【问题描述】:
我正在为访客网络使用 NAT 模式。我需要从客人外部访问我的机器。我已经设置 iptables 将主机上的特定端口转发到来宾上的端口 22,但这似乎不起作用。
我添加了这条规则:
# Port Forwardings
-A PREROUTING -i eth0 -p tcp --dport 9867 -j DNAT --to-destination 192.168.122.136:22
# Forward traffic through eth0 - Change to match you out-interface
-A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
当我从主机ssh 192.168.122.136 时,它运行良好,但是当我尝试ssh 192.168.122.136 -p 9867 时,它显示ssh: connect to host 192.168.122.1 port 9867: Connection refused
我已在 /etc/ufw/sysctl.conf 上启用端口转发
使用iptables -t nat -L表示规则设置在iptable上
DNAT tcp -- anywhere anywhere tcp dpt:9867 to:192.168.122.136:22
【问题讨论】: