Skip to content

Instantly share code, notes, and snippets.

@raminv80
Created July 24, 2015 05:24
Show Gist options
  • Save raminv80/58e21d804723f2de0adf to your computer and use it in GitHub Desktop.
Save raminv80/58e21d804723f2de0adf to your computer and use it in GitHub Desktop.
PPTP auto reconnect with Monit
...
#assuming the host behind vpn has local ip of 192.168.1.2
check host my_host_behind_vpn with address 192.168.1.2
# create a shell script at /usr/local/bin/start_pppd.sh
# Add your vpn connection setup there
# example conect of this file can be:
# pppd call my-vpn #to connect to pptp client
# sleep 5 #wait few seconds for connection to start
# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 dev ppp0 # route your traffic
start program "/usr/local/bin/start_pppd.sh"
stop program "/usr/bin/killall pppd"
#try to connect for 5 times with delay 15 sec interval
if failed icmp type echo count 5 with timeout 15 seconds then restart
if 5 restarts within 5 cycles then
# if still fails kill pptp client and retry
exec "/usr/bin/killall -9 pptp && /usr/local/bin/start_pppd.sh"
# if after an hour still fails stop trying
if 60 restarts within 60 cycles then timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment