Created
July 24, 2015 05:24
-
-
Save raminv80/58e21d804723f2de0adf to your computer and use it in GitHub Desktop.
PPTP auto reconnect with Monit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
#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