Posts: 9
Joined: Mon Mar 28, 2016 5:45 pm

Script to auto reboot if no VPN/Internet access

Wed Mar 30, 2016 8:58 pm

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

Posts: 17
Joined: Thu Mar 10, 2016 12:02 pm

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

Tue Apr 05, 2016 10:32 am

.Might this be a solution? (change to or similar. ... e-internet
Raspian Jessie 2016-02-26 _-=* If there are choices, why complain? *=-_
openSUSE LEAP 42.1 (3 pcs) _-=* Uppland, Sweden *=-_

Return to “Raspberry Pi OS”