Skip to content

Instantly share code, notes, and snippets.

@maurerle
Last active June 15, 2025 18:29
Show Gist options
  • Save maurerle/32bb6e31796d843c4d3bd84eeff0f733 to your computer and use it in GitHub Desktop.
Save maurerle/32bb6e31796d843c4d3bd84eeff0f733 to your computer and use it in GitHub Desktop.
#!/bin/bash
sudo apt-get install build-essential linux-source bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves bison linux-headers-amd64
tar xavf /usr/src/linux-source-$(uname -r | cut -d. -f1,2).tar.xz
cd linux-source-$(uname -r | cut -d. -f1,2)
# apply patch
wget -O wireguard.patch https://git.zx2c4.com/wireguard-linux/patch/?id=db9ae3b6b43c79b1ba87eea849fd65efa05b4b2e
patch -p1 < wireguard.patch
#rm wireguard.patch
cat /boot/config-$(uname -r) > .config
make menuconfig
# search for WireGuard (using /), go there and enable it as a module (M) in menuconfig
make modules_prepare
make prepare
#make modules M=drivers/net/wireguard
# the below one helped with an issue
make -C /lib/modules/$(uname -r)/build M=$(pwd)/drivers/net/wireguard modules
# install had some warnings, see below
sudo make -C /lib/modules/$(uname -r)/build M=$(pwd)/drivers/net/wireguard modules_install
sudo depmod -a
sudo update-initramfs -u
# sudo modinfo wireguard | grep filename
# should show something like
# filename: /lib/modules/6.1.0-37-amd64/extra/wireguard.ko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment