Home > Linux > Ubuntu server persistent auto reconnecting PPTP VPN connection

Ubuntu server persistent auto reconnecting PPTP VPN connection

I have set up a PPTP VPN client on my Ubuntu server. Unfortunately when the server reboots, the connection goes down and stays down. After a long search I found a solution on this website. It is simple bash script, which checks if the VPN server (which had the VPN ip of 10.8.3.0) is pingable. If not it restarts the PPTP VPN connection.

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

Linux , , ,

  1. Jurgen
    May 28th, 2011 at 19:08 | #1

    nice! thanks… this works perfectly for me!

  2. wildneuro
    July 17th, 2011 at 11:53 | #2

    thanks, this works for me too!

  3. Luis
    October 13th, 2011 at 10:10 | #3

    Perfect!!! :D

  1. No trackbacks yet.