Skip to content

Instantly share code, notes, and snippets.

@blueperson
Created January 2, 2017 14:12
Show Gist options
  • Save blueperson/d805efc8cefffe0e0b6aef69640357ba to your computer and use it in GitHub Desktop.
Save blueperson/d805efc8cefffe0e0b6aef69640357ba to your computer and use it in GitHub Desktop.
shadowsocks多端口随机
#ss-server 服务端(假设你的目前的服务端 ss 端口已经监听在 23 端口):
#-----------开始--------------
iptables -t nat -A PREROUTING -p tcp -m multiport --dport 81:1023 -j REDIRECT --to-ports 23
iptables -t nat -A PREROUTING -p udp -m multiport --dport 81:1023 -j REDIRECT --to-ports 23
#以下两条命令可选
service iptables save
service iptables restart
#-----------结束--------------
#ss-redir 本地端(104.224.156.199 自行修改成自己服务器 ip):
#-----------开始--------------
iptables -t nat -I OUTPUT 1 -d 104.224.156.199 -p tcp --dport 23 -j DNAT --to-destination 104.224.156.199:81-1023 --random
iptables -t nat -I OUTPUT 1 -d 104.224.156.199 -p udp --dport 23 -j DNAT --to-destination 104.224.156.199:81-1023 --random
#以下两条命令可选
service iptables save
service iptables restart
#openwrt
#/etc/init.d/firewall restart
#-----------结束--------------
#可使用 iptables -t nat -L -n --line-numbers 命令查看 nat 规则是否已经生效
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment