1
0
Fork 0
mirror of synced 2025-04-05 06:03:33 +03:00

Create linux-client.sh

This commit is contained in:
WangDaoO 2018-03-01 21:17:31 +08:00 committed by GitHub
parent 36208fa4ca
commit 528d864c0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

62
extras/linux-client.sh Normal file
View file

@ -0,0 +1,62 @@
#!/bin/bash
#your vpn server public ip
SERVER_IP=''
#Verify that a string contains another string
Include(){
bigStr=$1;
smallStr=$2;
result=$(echo $bigStr | grep $smallStr)
if [ -z "$result" ]
then
echo 0
else
echo 1
fi
}
mkdir -p /var/run/xl2tpd
touch /var/run/xl2tpd/l2tp-control
service strongswan restart
service xl2tpd restart
ipsec up myvpn
echo "c myvpn" > /var/run/xl2tpd/l2tp-control
route=`ip route`
echo ${route}
gw=${route#*default\ via\ }
gw=${gw%%\ *}
echo "your gateway is:${gw}"
while :
do
cfg=`ifconfig`
res=`Include "$cfg" "ppp0"`
if [ $res -eq 1 ]
then
echo "ppp0 already activated"
break
else
echo "waitting 1s"
sleep 1s
fi
done
route add ${SERVER_IP} gw $gw
route add default dev ppp0
echo "done"
ifconfig