Shadowsocks in Linux uses iptables random multiport ports

Source: Internet
Author: User
Tags iptables

OpenWrt Configure Iptables to randomly dnat a shadowsocks connection to a specific port:

  code is as follows copy code

iptables-t nat-a output-p TCP--dport 5688-m State--state new-m- -mode nth --every 4 --packet 0 -j DNAT --to-destination serverip:5688<br />
iptables -t nat -A OUTPUT -p tcp --d Port 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

The server side Dnat the port to which the client is connected to the Shadowsocks listening port:

The code is as follows Copy Code

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.