guy30000
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 8.8.8.8) 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.
client
dev tun
proto udp
resolv-retry infinite
remote-random
nobind
persist-key
persist-tun
auth-user-pass /etc/openvpn/pass.txt
ns-cert-type server
verb 3
mtu-test
explicit-exit-notify 1
server-poll-timeout 3
keepalive 120 600

quinness
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 192.168.1.1 to 8.8.8.8 or similar.
http://superuser.com/questions/378549/c ... 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”