Created
January 28, 2019 11:43
-
-
Save dcava/77049d346094d0771fe6c0cee0bf3079 to your computer and use it in GitHub Desktop.
Wireguard compile for synology
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.reddit.com/r/synology/comments/a2erre/guide_intermediate_how_to_install_wireguard_vpn/ | |
[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. | |
WARNING | |
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 https://github.com/SynologyOpenSource/pkgscripts-ng | |
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 https://netfilter.org/projects/libmnl/files/libmnl-1.0.4.tar.bz2 | |
tar xf libmnl-1.0.4.tar.bz2 | |
cd libmnl-1.0.4 | |
./configure | |
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: | |
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-6.2/build/ | |
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 System.map 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: | |
make | |
The relevant files are: | |
wireguard.ko | |
tools/wg | |
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 | |
And | |
sudo wg | |
should output interface: wg0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment