Skip to content

Instantly share code, notes, and snippets.

@ctrngk
Created September 23, 2018 10:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctrngk/5376fd9cb3fe5120dfc8b5491d0f69c2 to your computer and use it in GitHub Desktop.
Save ctrngk/5376fd9cb3fe5120dfc8b5491d0f69c2 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