How to reconnect to a VPN when connexion is lost?

Hi all,

I have being having troubles lately with my internet connexion, some random connection drops. When this happens the connexion with the VPN is lost and this makes me impossible to access my NAS outside my local network. HOWEVER, when you go to network settings it still appear as “connected” to the VPN.

I am sure that this is a problem connecting again to the VPN and not to internet, as I forced a disconnection with my router without the VPN on and it reconnects just fine.

I have marked the option of “Reconnect when the VPN connection is lost”, it doesn’t work. I tried this script that I could see recommended here several times but I had the following error:

Current status: 2 (Interrupted)

Standard output/error:

[I] There is 1 VPN profile. Continuing…

[W] Synology DSM reports VPN is not connected.

[I] Attempting to reconnect…

kill client …OK

/bin/bash: line 117: /usr/syno/etc/synovpnclient/vpnc_connecting: Permission denied

/bin/bash: line 118: /usr/syno/etc/synovpnclient/vpnc_connecting: Permission denied

/bin/bash: line 119: /usr/syno/etc/synovpnclient/vpnc_connecting: Permission denied

get arguemnt id: o1639771020

[W] Synology DSM reports VPN is not connected.

[E] VPN failed to reconnect. Exiting…

I do not know why I have this error or why it doesn’t work. I also not sure if this script will help as my VPN still appearing as connected, although it is not functional.

Any help with this issue, please? Thanks a lot.

Edit: The error was because I was not using “root” as the User, but still not working.

I use this.

https://gist.github.com/hannesbe/03020b0f9662a9e973f7cceadcdf0208

Sorry I don’t fully understand how to obtain the variables Route 1 and Route 2 :confused:

EDIT: Never mind, I just see it is an automatic process in one of the forks of the script.

Thanks!

It’s not automatic, it’s just there will be a default route. If your VPN setup gives you the routing that you need then no need to add additional routes.