我想使用 DNAT 通过端口重定向 ssh,并且我尝试通过 ssh 它command > username@IP_ADDRESS:10003
,但我收到了以下消息:
ssh: Could not resolve hostname IP_ADDRESS:10003: Name or service not known
我的配置看上去不错,需要做任何改变吗?
我使用的规则:
#default policy
iptables --policy INPUT DROP
iptables --policy OUTPUT DROP
iptables --policy FORWARD DROP
#connection states
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -i $EXTERNAL_ETH -p tcp --sport $OTHER_PORTS --dport 10003 -d $PUBLIC_IP -j DNAT --to-destination $SERVER2:22
iptables -A FORWARD -i $EXTERNAL_ETH -o $INTERNAL_ETH -p tcp --sport $OTHER_PORTS --dport 22 -d $SERVER2 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
这就是输出的样子
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
4 0 0 DNAT tcp -- eth0 * 0.0.0.0/0 $1111.1111.11.1 tcp spts:1024:65535 dpt:10003 to:10.0.0.3:22
Chain FORWARD (policy DROP 0 packets, 0 bytes)
10 0 0 ACCEPT tcp -- eth0 eth1 0.0.0.0/0 10.0.0.3 tcp spts:1024:65535 dpt:22 state NEW
答案1
测试此命令:
ssh username@IP_ADDRESS -p 10003