-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.sh
executable file
·34 lines (28 loc) · 1.35 KB
/
start.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
#!/usr/bin/env sh
# disable ip forwarding for better performance
# https://github.com/XTLS/Xray-core/discussions/59
# transparent proxy
# https://xtls.github.io/document/level-2/tproxy.html
# https://guide.v2fly.org/app/tproxy.html
ip route add local default dev lo table 100 # add routing table 100
ip rule add fwmark 1 table 100 # add rule for routing table 100
iptables -t mangle -N XRAY
iptables -t mangle -A XRAY -d 10.0.0.0/8 -j RETURN
iptables -t mangle -A XRAY -d 100.64.0.0/10 -j RETURN
iptables -t mangle -A XRAY -d 127.0.0.0/8 -j RETURN
iptables -t mangle -A XRAY -d 169.254.0.0/16 -j RETURN
iptables -t mangle -A XRAY -d 172.16.0.0/12 -j RETURN
iptables -t mangle -A XRAY -d 192.0.0.0/24 -j RETURN
iptables -t mangle -A XRAY -d 224.0.0.0/4 -j RETURN
iptables -t mangle -A XRAY -d 240.0.0.0/4 -j RETURN
iptables -t mangle -A XRAY -d 255.255.255.255/32 -j RETURN
iptables -t mangle -A XRAY -m mark --mark 0xff -j RETURN
iptables -t mangle -A XRAY -p tcp -j TPROXY --on-port $TPROXY_PORT --tproxy-mark 1
iptables -t mangle -A XRAY -p udp -j TPROXY --on-port $TPROXY_PORT --tproxy-mark 1
iptables -t mangle -A PREROUTING -j XRAY
iptables -t mangle -N DIVERT
iptables -t mangle -A DIVERT -j MARK --set-mark 1
iptables -t mangle -A DIVERT -j ACCEPT
iptables -t mangle -I PREROUTING -p tcp -m socket -j DIVERT
# start xray
/usr/bin/xray -config /etc/xray/config.json