Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Wireguard compile for synology
[Guide] [Intermediate] How to install Wireguard VPN
After lots of trial and error I figured out how to compile Wireguard for my DS718+. The first thing I did was search in this sub for a guide but didn't find any.
Wireguard is still experimental software. You should stay up-to-date with the daily snapshots.
This guide also requires familiarity with the command line and how to build software from source.
Setup Docker container
I used a docker container just so I don't clutter my laptop with stuff I don't need.
$ docker create -it --name synobuild ubuntu
$ docker start synobuild
$ docker exec -it synobuild bash
root@333b2b52d2c6:/# apt-get update
root@333b2b52d2c6:/# apt-get install git python3 wget
Setup toolchain
root@333b2b52d2c6:/# git clone
Download the toolchain for the DSM version and model you are running
root@333b2b52d2c6:/# pkgscripts-ng/EnvDeploy -v <DSM version> -p <CPU architecture>
You can look up the architecture here.
Example: DS718+ on DSM 6.2:
pkgscripts-ng/EnvDeploy -v 6.2 -p apollolake
Now, to switch to the build environment do:
chroot /build_env/ds.<CPU architecture>-<DSM version>
Build dependencies
Wireguard depends on libmnl
wget --no-check-certificate
tar xf libmnl-1.0.4.tar.bz2
cd libmnl-1.0.4
make install
cd ..
Build Wireguard
Download and unpack latest version from the download page.
Now you need to find the path to the kernel headers. In my case it is:
You may need to dig around in /usr/local a little to find the correct path.
This is what the folder contains for my setup:
sh-4.3# ls /usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-6.2/build/
Kconfig Makefile Module.symvers arch block certs crypto drivers firmware fs include init ipc kernel lib mm net samples scripts security sound tools usr virt
Edit the Makefile and change the KERNELDIR variable to point to the kernel headers you found.
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
In my case:
KERNELDIR ?= /usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-6.2/build/
All that is left to do is:
The relevant files are:
tools/wg-quick/linux.bash -> wg-quick script
Use docker cp to extract the files and copy them to your diskstation.
I put wg in /usr/local/bin/ and wireguard.ko in /lib/modules/wireguard.ko
To load the kernel module:
sudo insmod /lib/modules/wireguard.ko
You should now be able to do:
sudo ip link add wg0 type wireguard
sudo wg
should output interface: wg0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment