Iptables是防火墙软件了而shadowsocks是一个基于python的轻量级socks代理软件了,下面我们来看看shadowsocks使用Iptables随机多端口方法.
Openwrt下配置iptables将shadowsocks连接随机DNAT到特定端口,代码如下:
- iptables-tnat-AOUTPUT-ptcp--dport5688-mstate--stateNEW-mstatistic--modenth--every4--packet0-jDNAT--to-destinationserverip:5688
- iptables-tnat-AOUTPUT-ptcp--dport5688-mstate--stateNEW-mstatistic--modenth--every4--packet1-jDNAT--to-destinationserverip:5689
- iptables-tnat-AOUTPUT-ptcp--dport5688-mstate--stateNEW-mstatistic--modenth--every4--packet2-jDNAT--to-destinationserverip:5690//phpfensi.com
- iptables-tnat-AOUTPUT-ptcp--dport5688-mstate--stateNEW-mstatistic--modenth--every4--packet3-jDNAT--to-destinationserverip:5691
服务器端将客户端连接的端口DNAT到shadowsocks监听的端口,代码如下:
- iptables-tnat-APREROUTING-ptcp--dport5689:5691-jDNAT--to-destinationserverip:5688
#如果是分散的端口:
- iptables-tnat-APREROUTING-ptcp-mmultiport--dports3000,10000-jDNAT--to-destinationserverip:5688