Linux help

VPN Check if connection is up script

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

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

*/5 *   * * *   root    bash /root/



Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s