Difference between revisions of "OpenVPN Keep Alive Script"
Jump to navigation
Jump to search
Michael.mast (talk | contribs) (Created page with "<syntaxhighlight lang="BASH"> #!/bin/sh #This script is designed to monitor access to the destinatio...") |
Michael.mast (talk | contribs) |
||
Line 1: | Line 1: | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="bash"> |
#!/bin/sh | #!/bin/sh | ||
Latest revision as of 08:58, 23 May 2016
#!/bin/sh
#This script is designed to monitor access to the destination LAN, and ensure a tunnel is always up if needed.
#Written by Michael (TurboAAA) Mast. Please improve on this!
#1. Check if the tunnel is needed.
#2. If it is needed check if there is access to the vpn server.
#3. If there is access to the vpn server, clear any running instances and start a fresh instance.
ping -c 2 <LAN IP> &> /dev/null
A=$?
if [ $A = 0 ]; then
exit 0
elif [ $A = 1 ]; then
ping -c 2 <VPN PUBLIC IP> &> /dev/null
A=$?
if [ $A = 1 ]; then
exit 0
elif [ $A = 0 ]; then
killall openvpn
cd /root/
openvpn --config <OVPN CONFIG FILE>.ovpn --auth-user-pass /root/<VPN Credentials>
fi
fi