Script to Automatically Detect and Restart Linux PPTP Client

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.

Related posts:


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….



    11-Oct-2014 at 11:06 am

    What errors do you get?


18-Dec-2014 at 8:56 pm

ppt supports persist and maxtries to retry forever to reconnect. No need of additional script:


19-Feb-2015 at 2:23 pm


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 !



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:


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

seems to be a normal bug on Debian:

Nagarjuna Reddy

29-May-2018 at 4:19 pm

Hi i have phased some problems in ppp connection i tried to connection in automatically.
can you please solve that problem . I am using BeagleBoneBlack.

Leave a Reply

Visit our advertisers


Quick Poll

Are you using

Visit our advertisers