Hello,
It is possible to restart the VPN service when it no longer pings an address, through a script. However, it is not entirely clear, if you want to restart VPN on internet connection loss or after tunnel disconnects. A better description of the issue is needed.
The idea would be to continuously ping an address via VPN interface and, on occasion of failed pings, restart openvpn service.
For that you would need to login to router's WebUI, navigate to System -> Custom scripts section and add a similar script:
#!/bin/ash
while [ 1 ]; do #Marks the beginning of an infinite loop to repeatedly execute commands below
sleep 5 #A timer to wait 5 seconds, before executing following command
#Command below is to ping IP address over VPN tunnel and check ping status
ping -I <tunnel_interface> <ip_to_ping> -c 3 -q >/dev/null
ret=$? #$?
is a special variable containing the return code of the previously run command (0 = success, else = failure)
if [ $ret -ne 0 ]; then #If ping commands return failed status, following commands are executed
logger "State: Disconnected" #Creates log entry with the message
/etc/init.d/openvpn restart #Restarts VPN service
else #If ping commands return success status, following command is executed
logger "State: Connected" #Creates log entry with the message
fi #End of conditional statement
done #End of loop
Replace <*> accordingly.
The basic working is that every 5 seconds router sends 3 pings to the specified IP address via tunnel interface and, if no echo is received, openvpn service is restarted. It also adds log entries on the state of the VPN connection.
Best regards,