Last active
September 13, 2015 19:50
-
-
Save qzwpq/f7c28e70e82d0d533657 to your computer and use it in GitHub Desktop.
SoftEtherVPNClientからSoftEtherVPNServerにつなげるやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VPN_DIR="/usr/local/vpnclient" | |
VPN_CLIENT="${VPN_DIR}/vpnclient" | |
VPN_CMD="${VPN_DIR}/vpncmd" | |
SERVER="yourserver.softether.net" | |
timeout 5 getent hosts ${SERVER} > /dev/null | |
if [ "$?" != "0" ] ; then | |
echo "I couldn't get SERVER's ip" | |
${VPN_CLIENT} stop | |
exit 1 | |
fi | |
SERVER_IP=$(getent hosts ${SERVER} | awk '{print $1}') | |
ACCOUNT="youraccount" | |
NIC="yournic" | |
GATEWAY=$(ip r | awk '/^default/{print $3}') | |
start() { | |
ip r add ${SERVER_IP} via ${GATEWAY} | |
${VPN_CLIENT} start | |
sleep 1 | |
${VPN_CMD} localhost /CLIENT /CMD AccountConnect ${ACCOUNT} | |
dhcpcd vpn_${NIC} | |
} | |
stop() { | |
ip r del ${SERVER_IP} | |
${VPN_CLIENT} stop | |
} | |
case "$1" in | |
"start" ) | |
start | |
;; | |
"stop" ) | |
stop | |
;; | |
"restart" ) | |
stop | |
sleep 1 | |
start | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使い方
sudo ./vpn.sh start
sudo ./vpn.sh stop
sudo ./vpn.sh restart
注意
SERVER
VPN_DIR
ACCOUNT
NIC
は自分の環境に合わせて書き換えてください