adrianmihalko / raspberrypiwireguard

Install and configure WireGuard on Raspberry Pi (and others)
840 stars 77 forks source link

Wireguard not starting because of wrong kernel-headers? #11

Closed garret closed 5 years ago

garret commented 5 years ago

I was very happy to found out about your script on DrZZZ stream though I cannot get it working on my raspberry pi 3 B+. I am using dietpi as distribution. That is updated to the latest version.

I followed the initial part (before choosing for manual or semiautomatic script) and everything seems fine (I get the blue messages you show). I then went for the semiautomatic script but I get this error:

root@livingroom:~/wg_config# sudo wg-quick up wg0
[#] ip link add wg0 type wireguard
RTNETLINK answers: Operation not supported
Unable to access interface: Protocol not supported
[#] ip link delete dev wg0
Cannot find device "wg0"
root@livingroom:~/wg_config#

I found out that the wireguard module is not loaded:

root@livingroom:~# sudo modprobe wireguard && lsmod | grep wireguard
modprobe: FATAL: Module wireguard not found in directory /lib/modules/4.14.90-v7+

This is probably due to the kernel-headers installed do not correspond to the kernel I am using probably?

root@livingroom:~# sudo apt-get install linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.14.90-v7
E: Couldn't find any package by glob 'linux-headers-4.14.90-v7'
E: Couldn't find any package by regex 'linux-headers-4.14.90-v7'
root@livingroom:~#

Do you know how I could fix this issue? Thank you very much in advance!

adrianmihalko commented 5 years ago

Hi enzo,

"kernel-headers installed do not correspond to the kernel". Yes, this is the problem. For whatever reason your distributions ships different kernel headers than the current one.

I think your best option is:

1, install kernel source with rpi-source:

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

2, use raspbian

Hope it helps.

adrianmihalko commented 5 years ago

0, You wrote linux-headers-$(uname -r), but on raspbian it is actually: raspberrypi-kernel-headers - but maybe you are right and your distro is using the classic linux-headers-* package.

garret commented 5 years ago

I can see that I have also installed the package raspberrypi-kernel-headers

root@livingroom:~# 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.20181112-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@livingroom:~#

I guess I have to change distro... Thank you very much for your fast support!! 👍

adrianmihalko commented 5 years ago

We can try to debug this, but I think the result will be the same raspberrypi-kernel-headers is different version than the actual kernel. If you want to debug this, you can find me on Discord. Or you can always try to install sources with rpi-source, I used this some months ago.

garret commented 5 years ago

I am seeing that it should be possible to install wireguard on dietpi. I will try to ask support there since it deals with their distro.

https://github.com/Fourdee/DietPi/issues/2052

adrianmihalko commented 5 years ago

Cool, I hope you find a solution. If not, you can always contact me. I am closing this issue for now. :)

joevo2 commented 4 years ago

Have the same issue :( on RPI 3 as well

Rohlik commented 4 years ago

Also having this problem on RPi3+:

#apt-get install  "linux-headers-$(uname -r)"
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.19.114-v7
E: Couldn't find any package by glob 'linux-headers-4.19.114-v7'
E: Couldn't find any package by regex 'linux-headers-4.19.114-v7'
#uname -r
4.19.97-v7+
ukaeufe commented 4 years ago

I updated raspbian and reinstalled wireguard and wireguard-dkms and it worked again after a reboot: sudo -i apt-get upgrade apt-get update apt install --reinstall wireguard apt install --reinstall wireguard-dkms reboot

sudo wg show wg0

works again

joevo2 commented 4 years ago

I updated raspbian and reinstalled wireguard and wireguard-dkms and it worked again after a reboot: sudo -i apt-get upgrade apt-get update apt install --reinstall wireguard apt install --reinstall wireguard-dkms reboot

sudo wg show wg0

works again

Thanks! somehow it worked!

Msprg commented 3 years ago

For anyone struggling still with this issue, try:

sudo -s
apt update
apt install git bc bison flex libssl-dev -y
#This one will take a loong time
wget https://raw.githubusercontent.com/RPi-Distro/rpi-source/master/rpi-source -O /usr/local/bin/rpi-source && sudo chmod +x /usr/local/bin/rpi-source && /usr/local/bin/rpi-source -q --tag-update
rpi-source
apt remove wireguard wireguard-dkms wireguard-tools -y
reboot

lastly, after reboot:

#This might take just forever also...
sudo apt install wireguard -y

I was running those on RPi0w. Yeah, big mistake, took like an hour to be done... But it works!

foxpup commented 3 years ago

For anyone struggling still with this issue, try:

sudo -s
apt update
apt install git bc bison flex libssl-dev -y
#This one will take a loong time
wget https://raw.githubusercontent.com/RPi-Distro/rpi-source/master/rpi-source -O /usr/local/bin/rpi-source && sudo chmod +x /usr/local/bin/rpi-source && /usr/local/bin/rpi-source -q --tag-update
rpi-source
apt remove wireguard wireguard-dkms wireguard-tools -y
reboot

lastly, after reboot:

#This might take just forever also...
sudo apt install wireguard -y

I was running those on RPi0w. Yeah, big mistake, took like an hour to be done... But it works!

Thanx. That really helped me out. LLAP