[Synology] Auto connect VPN at startup
The built-in VPN client of Synology DSM 6 is excellent, but it lacks one key feature: being able to connect the VPN automatically after a reboot.
1. You need to have SSH enabled on the Synology
2. You need basic knowledge of Unix (
3. You need to have a working VPN configuration
Step 1: find your VPN config
The DSM comes with a command line tool to manage the VPN connection.
As you'll see the ergonomy is debatable, but it allows to initiate the connection from the shell.
This tool is
synovpnc, but before we can use it, we need the following file:
This is a temporary file that lives only a few seconds after you click "Connect" in the VPN configuration GUI.
Your mission is to click on "Connect" and
cat this file so you can see the configuration.
It should be something among thoses lines:
conf_id=o1481981647 conf_name=MyVpnConnection proto=openvpn
Step 2: initiate a VPN connection from the shell
Now we need to reproduce what the GUI does but in a script:
1. create the file
Let's create the file
/root/connect-vpn with the following content.
#!/bin/sh ID=o1481981647 cat >/usr/syno/etc/synovpnclient/vpnc_connecting <<END conf_id=$ID conf_name=MyVpnConnection proto=openvpn END synovpnc connect --id=$ID
chmod +x the file and execute it.
It should instantly make the GUI pass in the "Connecting" state.
Step 3: launch the script at startup
To make the Synology run the script at startup, we'll just add a symbolic link in the startup script folder:
ln -s /root/connect-vpn /usr/local/etc/rc.d/S99vpn
Now, reboot and enjoy :-)