raspberrypiwireguard icon indicating copy to clipboard operation
raspberrypiwireguard copied to clipboard

Raspbian: new kernel - wireguard not working

Open codegrau opened this issue 5 years ago • 17 comments

Hi there. Raspian updated to new kernel (and kernel headers) but wireguard won't start anymore

raspberrypi-kernel/stable,now 1.20190215-1 armhf [installed]
raspberrypi-kernel-headers/stable,now 1.20190215-1 armhf [installed]
# sudo modprobe wireguard
modprobe: FATAL: Module wireguard not found in directory /lib/modules/4.14.98-v7+
# sudo apt-get install raspberrypi-kernel-headers
Reading package lists... Done
Building dependency tree
Reading state information... Done
raspberrypi-kernel-headers is already the newest version (1.20190215-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

codegrau avatar Feb 21 '19 12:02 codegrau

Please try to install kernel sources manually and then reinstall Wireguard.

0, Install required packages for rpi-source

sudo apt-get install bc libncurses5-dev

1, Install kernel headers via rpi-source

https://github.com/notro/rpi-source

adrianmihalko avatar Feb 21 '19 15:02 adrianmihalko

Somehow this is solved now. Thanks!

codegrau avatar Feb 22 '19 13:02 codegrau

Which kernel versions has to be installed? I installed rpi-source, what I have to follow now?

dcal068 avatar Feb 28 '19 18:02 dcal068

Normally follow the guide on the main page. If you can't install Wireguard, because of kernel-headers are not found for your current kernel version, install kernel-source for your kernel version with rpi-source.

After that, try to install Wireguard again:

pi@raspberrypi:~ $ echo "deb http://deb.debian.org/debian/ unstable main" | sudo tee --append /etc/apt/sources.list.d/unstable.list
pi@raspberrypi:~ $ sudo apt-get install dirmngr 
pi@raspberrypi:~ $ sudo apt-key adv --keyserver   keyserver.ubuntu.com --recv-keys 8B48AD6246925553 
pi@raspberrypi:~ $ printf 'Package: *\nPin: release a=unstable\nPin-Priority: 150\n' | sudo tee --append /etc/apt/preferences.d/limit-unstable
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get install wireguard 
pi@raspberrypi:~ $ sudo reboot

(if you typed these commands before, probably you just want to run apt-get install wireguard)

If it still not working (or you have Rpi 1, Zero etc.), compile wireguard from source:

https://github.com/adrianmihalko/raspberrypiwireguard/wiki/Install-WireGuard-on-Raspberry-Pi-1,-2-(not-v1.2),-Zero,-Zero-W

adrianmihalko avatar Feb 28 '19 18:02 adrianmihalko

I think I have the same kernel version like @codegrau now with 4.14.

I have a new clean setup with raspbian stretch light on a rpi 1. I encountered the problem with manual compiling

2, Clone WireGuard repository and compile it

pi@raspberrypi:~` $ git clone https://git.zx2c4.com/WireGuard
pi@raspberrypi:~ $ cd WireGuard/src
pi@raspberrypi:~/WireGuard/src $ make

This error occured:

make[1]: *** /lib/modules/4.14.79+/build: file or directory not found. Finish.
Makefile:37: the rule for target module failed
make: *** [module] error 2

I solved it with the hint from @adrianmihalko

Please try to install kernel sources manually and then reinstall Wireguard.

0, Install required packages for rpi-source

sudo apt-get install bc libncurses5-dev

1, Install kernel headers via rpi-source

https://github.com/notro/rpi-source

WebMacke avatar Apr 03 '19 00:04 WebMacke

Im having a similar issue. I ran rpi-source, but Im still getting the following, any ideas?

pi@raspberrypi:~ $ modprobe wireguard modprobe: FATAL: Module wireguard not found in directory /lib/modules/4.19.36-v7+

pi@raspberrypi:~ $ sudo apt-get install raspberrypi-kernel-headersReading package lists... Done Building dependency tree
Reading state information... Done raspberrypi-kernel-headers is already the newest version (1.20190401-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

mbranchick avatar Apr 26 '19 01:04 mbranchick

hi @mbranchick I was having same issues, I was also on 4.19, and core problem was that I used rpi-update, which weirdly udates to untested/unstable versions.

This rouce explains: https://www.raspberrypi.org/documentation/linux/kernel/updating.md So I reverted back to 4.14 with:

sudo apt-get install --reinstall raspberrypi-bootloader raspberrypi-kernel

and then with sudo apt-get install raspberrypi-kernel-headers everything matched and the kernel mdule compilation went fine.

budius avatar May 01 '19 11:05 budius

Weirdly I get this too and for some reason following those steps gives me 4.19.42 now.

Unpacking raspberrypi-kernel (1.20190517-1) over (1.20190517-1) ...

Have they updated to 4.19 now!?

leearmstrong avatar May 19 '19 08:05 leearmstrong

Easiest way to get around the missing module is to remove/reinstall wireguard-dkms

andlil avatar Jun 01 '19 09:06 andlil

Here's a one-liner that fixes this; dpkg-reconfigure wireguard-dkms. Make it a habit to run this after every kernel upgrade and you'll be fine.

DenizenB avatar Aug 09 '19 13:08 DenizenB

Please try to install kernel sources manually and then reinstall Wireguard.

0, Install required packages for rpi-source

sudo apt-get install bc libncurses5-dev

1, Install kernel headers via rpi-source

https://github.com/notro/rpi-source

I'm receiving error when running sudo modprobe wireguard, and I am assuming that it is due to the kernel issue:

modprobe: FATAL: Module wireguard not found in directory /lib/modules/4.19.93-v7+

I didn't quite understand what is meant by "Install kernel headers via rpi-source". Could somebody elaborate on what the steps are for this?

mlauhalu avatar Jan 23 '20 22:01 mlauhalu

@frasskungin Here you find installation instructions - https://github.com/notro/rpi-source/wiki

Rohlik avatar May 28 '20 17:05 Rohlik

sudo tee -a /etc/rc.local <<EOF
if ! (modprobe wireguard 2> /dev/null); then
  dpkg-reconfigure wireguard-dkms || true
  modprobe wireguard || exit 1
fi
EOF

ns408 avatar May 29 '20 00:05 ns408

Found that removing and reinstalling wireguard-dkms got me working again. The dpkg-reconfigure command did not work for me.

sudo apt remove wireguard-dkms wireguard-tools sudo reboot sudo apt install wireguard-dkms wireguard wireguard-tools sudo reboot

Afterward my wg0 interface returned and wireguard server was back up.

Raybo128 avatar May 30 '20 21:05 Raybo128

@Raybo128 Thanks! somehow this worked for me!

dallasgroot avatar Jun 03 '20 23:06 dallasgroot

I tried most of the above. Ended up needing to run:

sudo -s
source /usr/src/wireguard-*/dkms.conf
dkms add wireguard/$PACKAGE_VERSION
dkms build wireguard/$PACKAGE_VERSION
dkms install wireguard/$PACKAGE_VERSION
reboot

in my case, I then needed to run the below:

sudo systemctl restart wg-quick@wg0 && pihole restartdns

thisaccountname avatar Jun 22 '20 22:06 thisaccountname

This command fixed it in my case:

apt-get install --reinstall raspberrypi-bootloader raspberrypi-kernel

mtnnn avatar Jul 25 '20 13:07 mtnnn