Auto Reconnect openvpn when connection lost - MrLiambi's blog

Breaking

My tweets

Advertisement

Auto Reconnect openvpn when connection lost

 Check the connection status :


#!/bin/bash

target=10.X.X.X

count=$( ping -c 1 $target | grep icmp* | wc -l )

if [ $count -eq 0 ]

then

    sudo service openvpn restart

    echo "Host is not Alive! Try again later.."

else

    echo "Yes! Host is Alive!"

fi


Then add execute privileges to your script


chmod +x script.sh


Then create a cron to run this every 2, 3, 4 ... minutes.




No comments:

Post a Comment