-
Notifications
You must be signed in to change notification settings - Fork 1
/
redsocks.sh
executable file
·70 lines (64 loc) · 1.89 KB
/
redsocks.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
set -x
# install and config redsocks
sudo apt install -y redsocks
sudo -E tee /etc/redsocks.conf >/dev/null << EOF
base {
log_debug = on;
log_info = on;
log = "file:/var/log/redsocks.log";
daemon = on;
user = redsocks;
group = redsocks;
redirector = iptables;
}
redsocks {
local_ip = 127.0.0.1;
local_port = 6666;
// ip = 10.239.4.80 child-prc;
ip = $INTEL_PROXY;
port = 1080;
type = socks5;
}
redudp {
local_ip = 127.0.0.1;
local_port = 8888;
ip = $INTEL_PROXY;
port = 1080;
udp_timeout = 30;
udp_timeout_stream = 180;
}
dnstc {
local_ip = 127.0.0.1;
local_port = 5300;
}
EOF
sudo tee /bin/proxy.sh >/dev/null << EOF
iptables -t nat -N REDSOCKS || true
iptables -t nat -F REDSOCKS
iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -p tcp -j DNAT --to-destination 127.0.0.1:6666
iptables -t nat -A REDSOCKS -p udp -j DNAT --to-destination 127.0.0.1:8888
iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
iptables -t nat -A PREROUTING -p tcp -j REDSOCKS
EOF
sudo chmod +x /bin/proxy.sh
sudo proxy.sh
sudo service redsocks restart
# settings for docker
sudo sysctl -w net.ipv4.conf.default.route_localnet=1
sudo sysctl -w net.ipv4.conf.all.route_localnet=1
grep "route_localnet" /etc/sysctl.conf
if [ $? -ne 0 ]; then
sudo tee -a /etc/sysctl.conf >/dev/null << EOF
net.ipv4.conf.all.route_localnet = 1
net.ipv4.conf.default.route_localnet = 1
EOF
fi