openvpn script reconnect - Raspberry Pi Forums


hello, search method reconnect raspserry pi3 server openvpn when connection go down
know script or commend line check if connection down , if down reconnect server?
in /etc/rc.local put command:
sudo openvpn /home/pi/vpn-config/dietpi.ovpn , work
if server go down or connection down not reconnect
thank lot

i don't know should need external script, openvpn rather reliable.

first shouldn't use rc.local, have systemd start tunnel you: edit /etc/default/openvpn , set autostart value want.

run bridged networks, here how tweaked system resilient connections. none of required, unless you're aiming availability.

on clients , servers run openvpn these options:

code: select all

float                 # accept unexpected ips resolv-retry infinite # try forever resolve peer name persist-tun           # upon restarts... persist-key ping-timer-rem        # don't ping until connected remote keepalive 30 120      # ping every 30s - inactivity restart 120s
openvpn should try reconnecting relentlessly.

happens quite local consumer-grade gateway going down while. i've seen jessie forfeit local network ip address if dhcp server stays down long enough (eg cable disconnected). @ point in time, interface stay there no ip , stop requesting 1 via dhcp.
on pi clients run pinger of own harnessed watchdog program. script tries ping local network gateway , known host on vpn network. after while take action:
- gateway vpn network down: restart openvpn (never happens)
- gateway down: reboot pi (happens sometimes)
pi's watchdog runs @ high frequency don't see fit network testing, using flag files can reduce frequency of pinger "test" program , of reboot/restart action "repair" program. i've posted recipe on forum this, if you're interested.

measure can set client try , connect more 1 server, in case server site goes down. supposedly can using name server, , dns serve ip addresses in round-robin fashion. except in case dnsmasq (local pi client), couldn't work. in client's openvpn config have instead:

code: select all

[top of config file] # using old-style rr w/ multiple connection points server-poll-timeout 90		# 90 secs before switching next remote # options <connections> must defined first ...  [all common options here] ... [bottom of config file] # supported connections # placed last options defined above apply <connection> blocks <connection> remote a.b.c.d  1111 # gateway @site1 lport 2222           # local port </connection> <connection> remote e.f.g.h  3333 # gateway @site2 lport 4444	        # local port </connection>
setup think availability good. if clients locked in cabinet, better.


raspberrypi



Comments