iptables转发端口的三种方法

佚名 2021-6-3 1,248 6/3

假如需要用A服务器554端口 转发B服务器2408端口
然后通过访问A服务器554达到访问B服务器2408的效果

方法1 (全部masq 傻瓜式 用这个会导致SS富强错误不可用)

iptables -t nat -A PREROUTING -p udp --dport 554 -j DNAT --to-destination 162.159.192.1:2408
iptables -t nat -A POSTROUTING -j MASQUERADE

方法2 [完全圆锥型NAT(Full cone NAT),即一对一(one-to-one)NAT]

iptables -t nat -A PREROUTING -p udp --dport 554 -j DNAT --to-destination 162.159.192.1:2408
iptables -t nat -A POSTROUTING -d 162.159.192.1 -p udp --dport 2408 -j SNAT --to-source 公网IPV4地址

方法3 (目前用这个 怕服务器公网IP会变)

iptables -t nat -A PREROUTING -p udp --dport 554 -j DNAT --to-destination 162.159.192.1:2408
iptables -t nat -A POSTROUTING -d 162.159.192.1 -p udp --dport 2408 -j MASQUERADE

 

- THE END -

佚名

7月11日16:53

最后修改:2021年7月11日
0

共有 0 条评论