Did you ever wonder how you can set up your Synology NAS' OpenVPN client to automatic reconnect to a lost OpenVPN server connection?
Hey, my name is "Tux" and this tutorial will show you how you can configure an automatic reconnection of your Synology NAS OpenVPN client after the connection to its OpenVPN server got lost.
Note
First of all make sure the OpenVPN connection is disconnected. Now open an SSH session with your local computer to your Synology NAS and prepare the following command (just prepare it but don't execute it yet!):
$ cat /usr/syno/etc/synovpnclient/vpnc_connecting
Now establish the OpenVPN connection and execute the prepared command simultaneously.
Explanation: During connection establishment the OpenVPN client creates temporarly a file called /usr/syno/etc/synovpnclient/vpnc_connecting
and holds it for a few seconds. This file contains an unique connection ID and other informations required for following steps in this tutorial.
The output should look like this:
conf_id=<myConnectionID>
conf_name=<myConnectionDescription>
proto=<myVPNType>
Now change to root
user:
$ sudo -i
Create the following script file…
$ vi /root/connectVPN.sh
…and add the following content:
#!/bin/sh ID=<myConnectionID> cat >/usr/syno/etc/synovpnclient/vpnc_connecting <<END conf_id=$ID conf_name=<myConnectionDescription> proto=openvpn END synovpnc connect --id=$ID
Save the file and quit the editor.
Now make the script executable:
$ chmod +x /root/connectVPN.sh
Now you can set up an according job via DSM's Task Scheduler which runs the script on according intervals as you prefer.
Appreciate my work?
Buy me a coffee or PayPal
Source(s):
[Synology] Auto connect VPN at startup