-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvpnclient
More file actions
executable file
·42 lines (42 loc) · 1.07 KB
/
vpnclient
File metadata and controls
executable file
·42 lines (42 loc) · 1.07 KB
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
#!/bin/bash
# chkconfig: 2345 99 01
# description: SoftEther VPN Client
DAEMON=/usr/local/vpnclient/vpnclient
LOCK=/var/lock/subsys/vpnclient
SERVER_IP=[SERVER_IP]
CLIENT_IP=[CLIENT_IP]
CLIENT_NETBLOCK=[CLIENT_NETBLOCK]
CLIENT_GATEWAY=[CLIENT_GATEWAY]
CLIENT_NETWORK=[CLIENT_NETWORK]
IP_TABLE=[IP_TABLE]
DEFAULT_ROUTE=$(ip route | grep "default.*")
test -x $DAEMON || exit 0
case "$1" in
start)
$DAEMON start
touch $LOCK
sleep 1
ip addr add ${CLIENT_IP}/${CLIENT_NETBLOCK} dev vpn_vpn
ip route add ${CLIENT_NETWORK}/${CLIENT_NETBLOCK} dev vpn_vpn src ${CLIENT_IP} table ${IP_TABLE}
ip route add default via ${CLIENT_GATEWAY} dev vpn_vpn table ${IP_TABLE}
ip route add ${SERVER_IP}/32${DEFAULT_ROUTE/default/}table ${IP_TABLE}
ip rule add from ${CLIENT_NETWORK}/${CLIENT_NETBLOCK} table ${IP_TABLE}
ip rule add to ${CLIENT_NETWORK}/${CLIENT_NETBLOCK} table ${IP_TABLE}
;;
stop)
ip route flush table vpntable
ip rule del table ${IP_TABLE}
ip rule del table ${IP_TABLE}
$DAEMON stop
rm $LOCK
;;
restart)
$DAEMON stop
sleep 3
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0