7

I recently installed Raspberry Pi OS on my Pi 3b. After some basic configuration and running raspi-config, I installed wireguard using apt and the debian backport repos, according to a tutorial.

I wasn't able to start the service though:

# systemctl start wg-quick@wg0
Job for wg-quick@wg0.service failed because the control process exited with error code.
See "systemctl status wg-quick@wg0.service" and "journalctl -xe" for details.

# journalctl -u wg-quick@wg0
raspberrypi systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
raspberrypi wg-quick[1773]: [#] ip link add wg0 type wireguard
raspberrypi wg-quick[1773]: Error: Unknown device type.
raspberrypi wg-quick[1773]: Unable to access interface: Protocol not supported
raspberrypi wg-quick[1773]: [#] ip link delete dev wg0
raspberrypi wg-quick[1773]: Cannot find device "wg0"
raspberrypi systemd[1]: wg-quick@wg0.service: Main process exited, code=exited, status=1/FAILURE
raspberrypi systemd[1]: wg-quick@wg0.service: Failed with result 'exit-code'.
raspberrypi systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.

The key lines are Unknown device type and Unable to access interface: Protocol not supported. It seems like wireguard isn't able to create a new wireguard interface, as if the kernel module didn't exist...

6

According to a comment on r/Wireguard, this error is caused by having the wrong kernel headers:

dkms packages (wireguard-dkms this time) need kernel headers for current kernel you have loaded (uname -a). As long as kernel is updated through apt or aptitude you should not run into problems, but if you update kernel with rpi-update you'll likely get newer kernel than what is available through package repository and there will be no headers available for it

The Foundation now offers headers for the rpi kernel, they just have to be installed. From the official online documentation on kernel headers:

If you are compiling a kernel module or similar, you will need the Linux Kernel headers. These provide the various function and structure definitions required when compiling code that interfaces with the kernel.

sudo apt install raspberrypi-kernel-headers

Note that it can take quite a while for this command to complete, as it installs a lot of small files. There is no progress indicator.

After installing raspberrypi-kernel-headers, and rebooting, Wireguard started normally.

2
  • 1
    The kernel and kernel header packages were updated yesterday. So start with sudo apt update; sudo apt dist-upgrade -y; sudo reboot. – Dougie Jul 24 '20 at 6:58
  • @Dougie So my answer might already have been obsolete by a day, SMH. Oh well, so long as the correct information is out there. You might want to put the dist-upgrade command in an answer so people can see and upvote it if it works. I probably won't pick a best answer because I already fixed it for me and won't be testing the dist-upgrade. – Keith Oct 12 '20 at 16:51
3

I haven't followed the tutorial you used but wireguard is heavy under development and there are some outdated installation tutorials on the web. Try this Wireguard installation that uses an official backport from Debian Bullseye. I have just tested it again with success.

1

For those that have the same issue but had a working wireguard set-up, (Linux headers were installed in the past) a bad kernel update may provoke a Linux headers mismatch.

I tried the following command:

sudo dpkg-reconfigure raspberrypi-kernel-headers

and that solved my issue.

1
  • I had a working setup, and dpkg-reconfigure command failed with an error. After using the buster backports repo (as suggested by Ingo's answer), everything worked again – randmin Jan 27 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.