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.
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:
Now change to
$ 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.
[Synology] Auto connect VPN at startup