Scripts for Synology DSM
This script can be used as a workaround for Synology DSM's less-than-ideal reconnect behavior when a VPN connection is lost. The actual magic in this script was originally written by users on a thread on the Synology Forum. This script just provides a user-friendly wrapper to their code. For more information, including installation instructions, refer to my blog post.
- 1.1.0: Extra customization options are included at the beginning of the script. Feel free to customize these to your liking.
- 1.2.0: The following exit codes are used:
0
: reconnect not needed1
: reconnect successful2
: reconnect failed3
: configuration error
- 1.3.0: An option is added to allow pinging a custom IP address or hostname to validate VPN connectivity.
- 1.4.0: An option is added to choose a specific VPN profile to reconnect, if multiple profiles exist. In this configuration, you could run multiple instances of this script, each targeting a specific VPN profile.
- 1.5.0: Options are added to run external scripts at various points. Note that the scripts must be executable, and if there are spaces in the script paths, you must either escape the spaces (e.g.
NO_RECONNECT_SCRIPT=/volume1/Scripts/script\ with\ spaces.sh
) or wrap the script paths in quotes (e.g.NO_RECONNECT_SCRIPT='/volume1/Scripts/script with spaces.sh'
). Community-maintained scripts compatible with these features are included in thereconnect-vpn.sh Community Scripts
directory.