Script to Automatically Detect and Restart Linux PPTP Client

  • 6

Script to Automatically Detect and Restart Linux PPTP Client

Category : How-to

Get Social!

Linux penguinThe default PPTP client for Linux does not automatically start on boot, or restart on a failed or dropped connection. I have written a short script to ping your VPN server gateway IP address and start the PPTP client if a ping does not succeed.

See my other post if you have not yet set up your PPTP VPN client.

Create this script and make it executable:

Add the below script to the file and change the following attributes for your own values:

  • your-vpn-host-or-ip-address
  • your-vpn-username
  • your-vpn-password

Add the following entry to your cron to execute the script every minute.

See my other post if you have not yet set up your PPTP VPN client.


6 Comments

Gary Alan Lee

10-Oct-2014 at 12:36 pm

I have tried this a number of times and for some I can’t get it to work on CentOS 5.11….. What am I doing wrong…? I added a pppd Call at the end of my rc.local config file and the vpn starts fine that way on boot but after about 15 or 20 min that darn system drops the VPN connection….. Bummer…!!!! I get a bunch of command errors when I try to fire-up your sh….

Gary

    james.coyle

    11-Oct-2014 at 11:06 am

    What errors do you get?

Pablo

18-Dec-2014 at 8:56 pm

ppt supports persist and maxtries to retry forever to reconnect. No need of additional script:
http://www.vionblog.com/debian-pptp-client-configuration/

http://linux.die.net/man/8/pppd

Ghosty

19-Feb-2015 at 2:23 pm

Hi,

Thanks for the script! i’ve got a quick qeustion. is it possible to use a command in this script for including the site configuration file stored in /etc/ppp/peers and /etc/ppp/chap-secrets ?

Thanks in advance !

Marcel

Oisín

25-Jul-2015 at 2:22 pm

For the start-on-reboot issue, I think this should suffice:

$ sudo update-rc.d pptpd defaults

Andres Gregori

15-Sep-2015 at 7:13 pm

In my case, I’ve setting cron from /etc/cron.d/pptp-cron file

How ever in order to works I’ve to put this at beggining file:

MAILTO=root
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

*/1 * * * * root /root/cron/pptp_cron.sh >> /var/log/pptp_pinger.log 2>&1

seems to be a normal bug on Debian:
http://serverfault.com/questions/98280/pptp-pon-fails-when-called-via-cron-debian

Leave a Reply

Visit our advertisers

Search

Visit our advertisers