Skip to content

Instantly share code, notes, and snippets.

@jiyifeng
Forked from x2c3z4/iptables.sh
Created December 23, 2016 14:09
Show Gist options
  • Save jiyifeng/2314e609b6e71755611c703b49f3b885 to your computer and use it in GitHub Desktop.
Save jiyifeng/2314e609b6e71755611c703b49f3b885 to your computer and use it in GitHub Desktop.
重定向google 的流量到其他的vps
#!/bin/sh
iptables -t nat -F
#create a new chain named SHADOWSOCKS
iptables -t nat -N SHADOWSOCKS
ips=(google.com www.google.com www.google.com.hk 74.125.203.0/24 64.233.188.0/24 114.134.80.0/24 64.18.0.0/20 64.233.160.0/19 66.102.0.0/20 66.249.80.0/20 72.14.192.0/18 74.125.0.0/16 108.177.8.0/21 173.194.0.0/16 207.126.144.0/20 209.85.128.0/17 216.58.192.0/19 216.239.32.0/19)
for ip in "${ips[@]}";do
iptables -t nat -A SHADOWSOCKS -p tcp -d $ip -j REDIRECT --to-ports 1081
done
iptables -t nat -A SHADOWSOCKS -p tcp -j RETURN
#iptables -t nat -A PREROUTING -p tcp -j SHADOWSOCKS
iptables -t nat -A OUTPUT -p tcp -j SHADOWSOCKS
iptables -t nat --list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment