This script sets up static client IPs when using OpenVPN of VPN Server package.
- Pass the client list like this:
"<username>:<ipsuffix>"(e. g."john:202"will make sure that userjohnwill be assigned IP10.8.0.202) - Please follow Synology/OpenVPN convention and only assign even numbers greater than:
2 + 4 * <max-clients> - Use IP-suffixes great enough in order not to conflict with the build in dynamic assignment
- The script is able to automatically update itself using
git.
- install the package
Git Serveron your Synology NAS, make sure it is running (requires sometimes extra action inPackage CenterandSSHrunning) - alternatively add SynoCommunity to
Package Centerand install theGitpackage (https://synocommunity.com/) - you can also use
entware-ng(https://github.com/Entware/Entware-ng)
- create a shared folder e. g.
sysadmin(you want to restrict access to administrators and hide it in the network) - connect via
sshto the NAS and execute the following commands
# navigate to the shared folder
cd /volume1/sysadmin
# clone the following repo
git clone https://github.com/alexanderharm/syno-openvpn-static-ip
# to enable autoupdate
touch syno-openvpn-static-ip/autoupdate- create a shared folder e. g.
sysadmin(you want to restrict access to administrators and hide it in the network) - copy your
synoOpenVpnStaticIp.shtosysadminusing e. g.File Stationorscp - make the script executable by connecting via
sshto the NAS and executing the following command
chmod 755 /volume1/syno-openvpn-static-ip/synoOpenVpnStaticIp.sh- run script manually (as root)
/volume1/sysadmin/syno-openvpn-static-ip/synoOpenVpnStaticIp.sh "<username1>:<ipsuffix1>" "<username2>:<ipsuffix2>"AND/OR
- create a task in the
Task Schedulervia WebGUI
# Type
Scheduled task > User-defined script
# General
Task: SynoOpenVpnStaticIp
User: root
Enabled: yes
# Schedule
Run on the following days: Daily
First run time: 00:00
Frequency: Every 1 hour(s)
Last run time: 23:00
# Task Settings
User-defined script: /volume1/sysadmin/syno-openvpn-static-ip/synoOpenVpnStaticIp.sh "<username1>:<ipsuffix1>" "<username2>:<ipsuffix2>"
/volume1/sysadmin/syno-openvpn-static-ip/synoOpenVpnStaticIp.sh "extbackup:202"