This is a special script for Synology NAS that helps you force Transmission's connection under the VPN you specify. It works with L2TP, PPTP, and OpenVPN connections. The script connects to VPN then sets Transmission to your VPN port. If it cannot find one, it will shut off VPN and prevent Transmission from working.
In other words, Transmission ONLY connects to VPN while other applications DO NOT!
To use this script, here are the steps you need to follow:
- Create the VPN using DiskStation Manager
- Install Transmission from SynoCommunity's repo
- Fill Out the VPN Settings/Optionals (below)
These are the descriptions of the variables that may be changed depending on your configuration. Examples are located inside the script. Please follow the exact format unless you know what you're doing. If you need help, feel free to open an issue on GitHub!
- VPN_CONFID - Synology Configuration ID (e.g. l1234567890, instructions below)
- VPN_CONFNAME - Synology Configuration Name (l2tpclient, pptpclient, or ovpnclient)
- VPN_PROTO - Synology Protocol (l2tp, pptp, or openvpn)
- VPN_UINAME - Synology VPN Name (Control Panel > Network > Network Interface)
- VPN_TYPE - The type of connection you will route though (ppp for L2TP/PPTP VPN, or tun for OpenVPN)
- VPN_INTERFACE - The default interface you will be connecting to (ppp0 for L2TP/PPTP, or tun0 for OpenVPN)
- VPN_RETRY - How many retries (times) if VPN fails to connect (default is 10)
- VPN_INTERVAL - The time (in seconds) to wait between each retry (default is 30)
- PORT_FWD - Carries an additional port forwarding check (default is empty, 51413 for Transmission default)
- IP_CHECK - Which URL to use to check your external IP address (default is http://ipinfo.io/ip)
- TRANS_USER - The user running under Transmission (default is transmission)
- TRANS_GROUP - The group of Transmission's user (default is users)
- TRANS_VAR - Path where the settings.json file is located (full path, no ending backslash)
- TRANS_SSSS - Path where the Transmission start-stop-status file is located (full path)
To retrieve the VPN_CONFID, follow these steps:
- SSH or Telnet into your Synology NAS Box
- Type cd /usr/syno/etc/synovpnclient/
- Type cd PROTOCOL (Replace PROTOCOL with l2tp, openvpn, or pptp)
- Type in ls -l to list out the files
- Find a file called connect_l1234567890
- Copy the text l1234567890 to the VPN_CONFID above
- Type exit once to logout of SSH or Telnet
NOTE: l1234567890 is an example. Each configuration ID (per VPN connection) is UNIQUE and YOU MUST connect to your Synology NAS though SSH or Telnet to retrieve it.
If you want to automate the script, you can use the Task Scheduler application provided inside the DiskStation Manager. Make sure the script is ran under root to prevent any issues occurring.
This script is purely useful for checking if your Transmission connection is working properly, and breaks Transmission if the VPN connection is off to prevent a leak. Here is one scenario where I would use it:
- Run /volume1/transmissionvpn.sh repair every 1 or 5 minutes.
Before you use this script, use the following commands:
- sh transmissionvpn.sh install - Installer. Stops VPN, binds 127.0.0.1 to Transmission
- sh transmissionvpn.sh uninstall - Uninstaller. Stops VPN, binds 0.0.0.0 to Transmission
To run this script, use the following commands:
- sh transmissionvpn.sh start - Start. Starts the VPN, binds VPN address to Transmission
- sh transmissionvpn.sh stop - Stop. Stops the VPN, binds 127.0.0.1 to Transmission
- sh transmissionvpn.sh repair - Repair. Fixes stalled VPNs, decides which IP address to bind
NOTE: If the script is located in /volume1/examplefolder/, navigate to that folder (using the cd command) before executing the commands above.