Last active
December 13, 2020 09:23
-
-
Save celeron633/49f24e49f8d03e7b2f5b64f102283759 to your computer and use it in GitHub Desktop.
proxy all tcp and udp traffic via ss-redir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#TCP | |
iptables -t nat -N SHADOWSOCKS_TCP | |
iptables -t nat -A SHADOWSOCKS_TCP -d 123.456.789.111/32 -j RETURN | |
iptables -t nat -A SHADOWSOCKS_TCP -d 0.0.0.0/8 -j RETURN | |
iptables -t nat -A SHADOWSOCKS_TCP -d 10.0.0.0/8 -j RETURN | |
iptables -t nat -A SHADOWSOCKS_TCP -d 127.0.0.0/8 -j RETURN | |
iptables -t nat -A SHADOWSOCKS_TCP -d 169.254.0.0/16 -j RETURN | |
iptables -t nat -A SHADOWSOCKS_TCP -d 172.16.0.0/12 -j RETURN | |
iptables -t nat -A SHADOWSOCKS_TCP -d 192.168.0.0/16 -j RETURN | |
iptables -t nat -A SHADOWSOCKS_TCP -d 224.0.0.0/4 -j RETURN | |
iptables -t nat -A SHADOWSOCKS_TCP -d 240.0.0.0/4 -j RETURN | |
iptables -t nat -A SHADOWSOCKS_TCP -p tcp -j REDIRECT --to-ports 12345 | |
iptables -t nat -A PREROUTING -j SHADOWSOCKS_TCP | |
#UDP | |
#增加IP mark, tproxy转发需要 | |
ip rule add fwmark 0x01/0x01 table 100 | |
ip route add local 0.0.0.0/0 dev lo table 100 | |
iptables -t mangle -N SHADOWSOCKS_UDP | |
iptables -t mangle -A SHADOWSOCKS_UDP -d 123.456.789.111/32 -j RETURN | |
iptables -t mangle -A SHADOWSOCKS_UDP -d 0.0.0.0/8 -j RETURN | |
iptables -t mangle -A SHADOWSOCKS_UDP -d 10.0.0.0/8 -j RETURN | |
iptables -t mangle -A SHADOWSOCKS_UDP -d 127.0.0.0/8 -j RETURN | |
iptables -t mangle -A SHADOWSOCKS_UDP -d 169.254.0.0/16 -j RETURN | |
iptables -t mangle -A SHADOWSOCKS_UDP -d 172.16.0.0/12 -j RETURN | |
iptables -t mangle -A SHADOWSOCKS_UDP -d 192.168.0.0/16 -j RETURN | |
iptables -t mangle -A SHADOWSOCKS_UDP -d 224.0.0.0/4 -j RETURN | |
iptables -t mangle -A SHADOWSOCKS_UDP -d 240.0.0.0/4 -j RETURN | |
iptables -t mangle -A SHADOWSOCKS_UDP -p udp -j TPROXY --on-port 12345 --on-ip 0.0.0.0 --tproxy-mark 0x1/0x1 | |
iptables -t mangle -A PREROUTING -j SHADOWSOCKS_UDP | |
the 'SHADOWSOCKS_UDP' and 'SHADOWSOCKS_TCP' should be the ss-redir listen port |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment