I'm trying to get Wireguard going on my RPi, just to mess around with it. I think I correctly followed the various directions I've seen about how to get up-and-running, but I can't find the raspberrypi-kernel-headers package mentioned in a couple places, so when I install the wireguard package the module can't be built (I think) and is thus unavailable to the kernel when I try to bring up that interface. I've tried various apt search commands to see if the package name has changed, and see no indication in my reading that it would be in some optional repository. Here's my version info:

# uname -a
Linux raspberrypi 5.4.72-v7l+ #1356 SMP Thu Oct 22 13:57:51 BST 2020 armv7l GNU/Linux

Here's the sum of my various sources.list type files:

# cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'$ apt search raspberrypi-kernel-headers

Sorting... Done Full Text Search... Done

deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
deb http://deb.debian.org/debian/ unstable main
deb http://httpredir.debian.org/debian buster-backports main contrib non-free
#deb http://archive.raspberrypi.org/debian/ buster main
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ buster main

I'm not the sharpest tool in the shed, but I think that uncommented deb-src line with "rpi" at the end should make kernel sources available to me. I must be missing something.

edit in response to comments:

Lack of a raspberrypi-kernel-headers package:

$ apt search raspberrypi-kernel-headers
Sorting... Done
Full Text Search... Done

Why "I think" the module isn't built: One, one of the things I read indicated the wireguard module automatically on install. Two, I don't have the necessary headers (see apt search result above). Taken together, it seems highly unlikely that I have a workable wireguard module.

/lib/modules directory contents:

$ ls /lib/modules
5.4.72+  5.4.72-v7+  5.4.72-v7l+  5.4.72-v8+

I'm not sure quite what to look for, but uname -a suggests I should poke around in 5.4.72-v7l+, so I tried that:

$ find /lib/modules/5.4.72-v7l+/ -type f | xargs egrep -li wireguard | wc -l

Similarly, I don't find "wg" or "wireguard" in any of the filenames. https://upcloud.com/community/tutorials/get-started-wireguard-vpn/ $ find /lib/modules/5.4.72-v7l+/ -type f | egrep -i 'wireguard|wg' | wc -l 0

Just for completeness, here's the output I get when trying to start the wireguard module. Rereading the output, I get the impression there is a wireguard module to load, but it doesn't load properly.

# systemctl status [email protected] | cat
● [email protected] - WireGuard via wg-quick(8) for wg0
   Loaded: loaded (/lib/systemd/system/[email protected]; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2021-01-17 08:21:00 CST; 1 day 4h ago
     Docs: man:wg-quick(8)
 Main PID: 451 (code=exited, status=1/FAILURE)

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

I checked out the [email protected] file and decided to try explicitly up'ing the service:

# wg-quick up wg0
[#] ip link add wg0 type wireguard
Error: Unknown device type.
Unable to access interface: Protocol not supported
[#] ip link delete dev wg0
Cannot find device "wg0"

Sure enough, there is no /dev/wg0. I don't recall seeing an explicit command to "makedev /dev/wg0" (or whatever modern Linux device creation incantation is). Is that maybe all that's wrong? I don't see a makedev command on my system. apt search shows me there is a makedev package, but that it's not installed. Install and start from scratch? (It never occurred to me that something as basic as makedev wouldn't simply be part of the standard suite of admin tools.)

Thanks to the other commenters for the references to Git and pivpn. I'll check them out if I'm completely unsuccessful trying the normal route.

Thanks GAD3R. I am much further along. The raspberrypi-kernel-headers are installed and I see a module:

# uname -a
Linux raspberrypi 5.4.83-v7l+ #1379 SMP Mon Dec 14 13:11:54 GMT 2020 armv7l GNU/Linux
# find /lib/modules/5.4.83-v7l+ -type f  | xargs egrep -li wireguard


systemctl enable wg-quick@wg0

runs with no output, but modprobe complains

# modprobe wireguard
modprobe: FATAL: Module wireguard not found in directory /lib/modules/5.4.83-v7l+

The location of the .ko file seems a little odd. There are no other .ko files at that level, just directories containing .ko files.

# ls -ltr /lib/modules/5.4.83-v7l+/kernel/net
total 296
-rw-r--r-- 1 root root 151996 Jan 20 13:35 wireguard.ko
drwxr-xr-x 3 root root   4096 Jan 20 13:40 sunrpc
drwxr-xr-x 3 root root   4096 Jan 20 13:40 bridge
drwxr-xr-x 5 root root   4096 Jan 20 13:40 bluetooth
drwxr-xr-x 2 root root   4096 Jan 20 13:40 batman-adv
# ls -ltr /lib/modules/5.4.83-v7l+/kernel/net/ipv4
total 260
-rw-r--r-- 1 root root  6424 Jan  7 09:54 xfrm4_tunnel.ko
-rw-r--r-- 1 root root  9184 Jan  7 09:54 udp_tunnel.ko
-rw-r--r-- 1 root root  8656 Jan  7 09:54 tunnel4.ko
-rw-r--r-- 1 root root  6096 Jan  7 09:54 tcp_westwood.ko
-rw-r--r-- 1 root root  7980 Jan  7 09:54 tcp_htcp.ko
-rw-r--r-- 1 root root  6152 Jan  7 09:54 tcp_diag.ko
-rw-r--r-- 1 root root  8140 Jan  7 09:54 tcp_bic.ko
-rw-r--r-- 1 root root 13428 Jan  7 09:54 tcp_bbr.ko
-rw-r--r-- 1 root root 17080 Jan  7 09:54 ip_vti.ko
-rw-r--r-- 1 root root 28112 Jan  7 09:54 ip_tunnel.ko
-rw-r--r-- 1 root root 15232 Jan  7 09:54 ipip.ko
-rw-r--r-- 1 root root 31008 Jan  7 09:54 ip_gre.ko

Messing around with kernel functionality takes me way out of my depth, and I have no good install to compare it with. FWIW, I am looking at this how-to page.

  • Use this: github.com/RPi-Distro/rpi-source it gets the source for your current kernel and sets up the kernel build environment.
    – Dougie
    Jan 17, 2021 at 16:49
  • Welcome, Skip, but a little more information is needed before anyone can provide a useful opinion. 1) Cut n' paste the output of apt search raspberrypi-kernel-headers. 2) Output from ls /lib/modules, 3) Please explain in detail what "I think" refers to in "when I install the wireguard package the module can't be built (I think)". Do you have any reason beyond what is here to believe that? Presumably you did something to try and compile the module, and there was some kind of output from that. Edit those into the question (don't just leave them in comments).
    – goldilocks
    Jan 17, 2021 at 18:46
  • if all else fails - install pivpn - it makes wireguard easy (though, doesn't support IPv6, which is a shame) Jan 18, 2021 at 8:22
  • I apologize for responding in this fashion, but can someone explain why this thread was closed? I tried to be as complete in my question as I thought reasonable. I was busy yesterday and didn't get onto responding to the comments pronto, but I eventually did. I'm new here, and don't understand the "details or clarity" business. Mystified...
    – Skip
    Jan 19, 2021 at 14:12
  • 1
    apt search raspberrypi-kernel-headers should return a package, possibly this is a misconfiguration in /etc/apt/sources.list[.d/].
    – goldilocks
    Jan 19, 2021 at 15:37

1 Answer 1


Installing the kernel headers

Your /etc/apt/sources.list.d/raspi.list is misconfigurated , you should have

deb http://archive.raspberrypi.org/debian/ buster main

(which provide the raspberrypi-kernel-headers package.)

instead of :

deb http://deb.debian.org/debian/ unstable main

(debian unstable repository, it will break your system if an apt-preferences file isn't set correctly.) There is no raspberrypi-kernel-headers package in this debian repository which explain why apt search return nothing.

Then run:

sudo apt update
apt policy raspberrypi-kernel-headers

sample output:

  Installed: (none)
  Candidate: 1.20210108-1
  Version table:
     1.20210108-1 500
        500 http://archive.raspberrypi.org/debian buster/main armhf Packages

Install it:

sudo apt install raspberrypi-kernel-headers

Installing WireGuard and loading the kernel module

Append testing to your sources repositories:

printf "%s\n" "deb http://archive.raspbian.org/raspbian testing main" | \
sudo tee  /etc/apt/sources.list.d/testing.list

important: Create a preferences file:

cat <<EOF | sudo tee /etc/apt/preferences.d/testing-preferences
Package: *
Pin: release a=testing
Pin-Priority: 50

Install dkms and wireguard:

sudo apt update
sudo apt install dkms
sudo apt install wireguard

The package wireguard is only available from testing, the kernel module should built correctly through dkms.

Loding the kernel module (-v = with verbosity):

sudo modprobe -v wireguard

sample output:

insmod /lib/modules/5.4.83-v7+/kernel/net/ipv4/udp_tunnel.ko 
insmod /lib/modules/5.4.83-v7+/kernel/net/ipv6/ip6_udp_tunnel.ko 
insmod /lib/modules/5.4.83-v7+/kernel/net/wireguard.ko 
  • 1
    This should have been/was obvious from the beginning -- I'm sorry for dropping the ball on that, Skip. I got distracted by the fact that you said you "couldn't find the package" but didn't literally paste apt search failing; not everyone is aware of this so I stepped off at But how did you look (did you really look)?, then when you filled that in I did not bother reading the question over again...
    – goldilocks
    Jan 19, 2021 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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