4 SOCKS5_IP=${SOCKS5_IP:-127.0.0.1}
5 SOCKS5_PORT=${SOCKS5:-1080}
6 DNS_SERVER=${DNS_SERVER:-10.248.2.1}
8 sudo apt-get install -y redsocks iptables
10 cat <<EOF | sudo tee /etc/redsocks.conf
14 log = "file:/root/proxy.log";
16 redirector = iptables;
28 echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
29 sudo iptables -t filter -F
30 sudo iptables -t mangle -F
31 sudo iptables -t nat -F
33 sudo iptables -t nat -N REDSOCKS || true
34 sudo iptables -t nat -A REDSOCKS -d 0.0.0.0/16 -j RETURN
35 sudo iptables -t nat -A REDSOCKS -d 10.0.0.0/16 -j RETURN
36 sudo iptables -t nat -A REDSOCKS -d 127.0.0.0/16 -j RETURN
37 sudo iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
38 sudo iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
39 sudo iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
40 sudo iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
41 sudo iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
42 sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 6666
43 sudo iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
44 sudo iptables -t nat -A PREROUTING -p tcp -j REDSOCKS
45 sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
46 sudo iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to-destination $DNS_SERVER
48 sudo service redsocks restart
49 wget --no-proxy www.sina.com.cn -O /dev/null