{{ :supportukraine.gif|}}
====== Synology: OpenVPN client: Auto reconnect via script with Tux ======
{{en:tux.png |Hey, my name is "Tux"!}} **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 thoughts =====
This tutorial assumes that you already have set up a working //OpenVPN// connection between your //Synology// NAS' //OpenVPN// client and the according //OpenVPN// server!
\\
===== Start of tutorial =====
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=
\\ conf_name=
\\ proto=''
\\
\\ Now change to ''root'' user:
$ sudo -i
Create the following script file...
$ vi /root/connectVPN.sh
...and add the following content:
#!/bin/sh
ID=
cat >/usr/syno/etc/synovpnclient/vpnc_connecting <
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.
\\
===== End of tutorial =====
\\
\\
Appreciate my work? \\ [[https://www.buymeacoffee.com/fabioU|Buy me a coffee]] {{:buymeacoffee.png|}} or [[https://www.paypal.com/donate/?hosted_button_id=TH8Q3NTJCAJBA|PayPal]] {{:paypal.png|}}
\\
\\
**Source(s):**
\\
[[https://blog.benoitblanchon.fr/synology-auto-connect-vpn-at-startup|[Synology] Auto connect VPN at startup]]
{{htmlmetatags>metatag-robots=()}}