Skip to content

Instantly share code, notes, and snippets.

@qzwpq
Last active September 13, 2015 19:50
Show Gist options
  • Save qzwpq/f7c28e70e82d0d533657 to your computer and use it in GitHub Desktop.
Save qzwpq/f7c28e70e82d0d533657 to your computer and use it in GitHub Desktop.
SoftEtherVPNClientからSoftEtherVPNServerにつなげるやつ
#!/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
@qzwpq
Copy link
Author

qzwpq commented Jul 19, 2015

使い方

  • sudo ./vpn.sh start
  • sudo ./vpn.sh stop
  • sudo ./vpn.sh restart

注意

SERVER VPN_DIR ACCOUNT NICは自分の環境に合わせて書き換えてください

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment