Openwrt下配置iptables将shadowsocks连接随机DNAT到特定端口:
代码如下 | 复制代码 |
iptables -t nat -A OUTPUT -p tcp --dport 5688 -m state --state NEW -m statistic --mode nth --every 4 --packet 0 -j DNAT --to-destination serverip:5688<br /> iptables -t nat -A OUTPUT -p tcp --dport 5688 -m state --state NEW -m statistic --mode nth --every 4 --packet 1 -j DNAT --to-destination serverip:5689<br /> iptables -t nat -A OUTPUT -p tcp --dport 5688 -m state --state NEW -m statistic --mode nth --every 4 --packet 2 -j DNAT --to-destination serverip:5690<br /> iptables -t nat -A OUTPUT -p tcp --dport 5688 -m state --state NEW -m statistic --mode nth --every 4 --packet 3 -j DNAT --to-destination serverip:5691 |
服务器端将客户端连接的端口DNAT到shadowsocks监听的端口:
代码如下 | 复制代码 |
iptables -t nat -A PREROUTING -p tcp --dport 5689:5691 -j DNAT --to-destination serverip:5688<br /> #如果是分散的端口:<br /> iptables -t nat -A PREROUTING -p tcp -m multiport --dports 3000,10000 -j DNAT --to-destination serverip:5688 |
时间: 2024-10-28 04:36:12