-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtun_confg.sh
More file actions
42 lines (34 loc) · 963 Bytes
/
tun_confg.sh
File metadata and controls
42 lines (34 loc) · 963 Bytes
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
#from mellow to work with tun2socks
DNS1=8.8.8.8
DNS2=8.8.4.4
TUN_GW=10.255.0.1
TUN_ADDR=10.255.0.2
TUN_MASK=255.255.255.0
ORIG_GW=`ip route get 1 | awk '{print $3;exit}'`
ORIG_ST_SCOPE=`ip route get 1 | awk '{print $5;exit}'`
ORIG_ST=`ip route get 1 | awk '{print $7;exit}'`
config_route() {
# Give some time for Mellow to open the TUN device.
ip addr add $TUN_ADDR dev tun1
ip link set tun1 up
sleep 3
ip route del default table main
ip route add default via $TUN_GW table main
ip route add default via $ORIG_GW dev $ORIG_ST_SCOPE table default
ip rule add from $ORIG_ST table default
echo "Routing table is ready."
}
recover_route() {
ip rule del from $ORIG_ST table default
ip route del default table default
ip route del default table main
ip route add default via $ORIG_GW table main
echo "Routing table recovered."
}
pause_read() {
echo 'press enter key to continue'
read
}
config_route
pause_read
recover_route