Page 1 of 1

Script to auto reboot if no VPN/Internet access

Posted: Wed Mar 30, 2016 8:58 pm
by guy30000
I have a VPN setup on my pi to connect on boot but the connection is unstable due to my on network issues. The "Keepalive 120 600" command doesn't help. When connection returns after an outage I have no access to the interent at all until I reboot. This is fine as I only want it to communicate through the VPN, but I think it is what prevents the keep alive from working.
So what I'd like to do is setup a script instead to ping something (like google every 2 minutes and if no responses heard in 10 to reboot. Just like the keepalive would do but reboot instead of try to restart the VPN. I'm rather inexperienced with linux so need some advise. I'd like a script to do this, and if you have some extra time some explanation on it as I'm trying to learn. Though with just the script I could tinker with it and figure it all out.

Thanks for your help.
Below is the start script of my VPN in case there is simply something missing from there to make it work right.
dev tun
proto udp
resolv-retry infinite
auth-user-pass /etc/openvpn/pass.txt
ns-cert-type server
verb 3
explicit-exit-notify 1
server-poll-timeout 3
keepalive 120 600

Re: Script to auto reboot if no VPN/Internet access

Posted: Tue Apr 05, 2016 10:32 am
by quinness
.Might this be a solution? (change to or similar. ... e-internet