This script is awesome – it does exactly what it says it will: Check the connection and restart the service if it’s down. (it pings the destination, and restarts a service when the ping fails)

ping -c3 10.8.3.0 > pingreport
result=`grep "0 received" pingreport`
truncresult="`echo "$result" | sed 's/^\(.................................\).*$/\1/'`"
if [[ $truncresult == "3 packets transmitted, 0 received" ]]; then
pon company-vpn
fi

I execute this script every five minutes, by editing the /etc/crontab file and added the following rule:

*/5 *   * * *   root    bash /root/vpn-check.sh

Reference:
http://basvandijk.eu/2011/05/12/ubuntu-server-persistent-auto-reconnecting-pptp-vpn-connection/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s