我想要将所有tcp出站stream量从192.168.2.99:16881路由到一个接口:tun1我也想要从$ PORT上tun1的所有tcp传入stream量redirect到192.168.2.99:16881。
我现在所拥有的是这个脚本:
#1 Get the PORT PORT=`./port_forwarding.sh` #2 Accept incoming traffinc on $PORT iptables -A INPUT -p tcp --dport $PORT -j ACCEPT #3 Route all TCP incoming trafinc on $PORT to 192.168.2.99:16881 iptables -t nat -A PREROUTING -j DNAT -p tcp --dport $PORT --to-destination 192.168.2.99:16881 #4 Route all TCP outgoing traffic from 192.168.2.99 to tun1 iptables -t nat -A POSTROUTING --out-interface tun1 -j MASQUERADE -s 192.168.2.99
这些规则似乎不起作用,我应该改变什么?
2&3:我应该指定接口tun1吗?
4:如何指定源端口?