-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrc.local
41 lines (37 loc) · 1.22 KB
/
rc.local
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
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -j MASQUERADE
sleep 10
GW=`netstat -rn|grep '0.0.0.0'|awk '{print $2}'|head -1`
HOST_IP=$(ifconfig |grep broadcast |awk '{print $2}')
sudo ip rule add fwmark 0x01/0x01 table 100
sudo ip route add local 0.0.0.0/0 dev lo table 100
sudo iptables -t mangle -N V2RAY
sudo iptables -t mangle -I V2RAY -d 192.168.0.0/16 -j RETURN
sudo iptables -t mangle -I V2RAY -d $GW/32 -j RETURN
for line in $HOST_IP
do
#echo $line
sudo iptables -t mangle -I V2RAY -d $line/32 -j RETURN
done
sudo iptables -t mangle -I V2RAY -d 127.0.0.1/32 -j RETURN
sudo iptables -t mangle -A V2RAY -p udp -j TPROXY --on-port 12345 --tproxy-mark 0x01/0x01
sudo iptables -t mangle -A V2RAY -p tcp -j TPROXY --on-port 12345 --tproxy-mark 0x01/0x01
sudo iptables -t mangle -A PREROUTING -j V2RAY
exit 0