Wireguard: Attempting to Install and Configure Wireguard Fails with “Unknown device type” and “FATAL: Module wireguard not found in directory”

After installing a new kernel on Ubuntu the interface could not be brought up because it did not exist anymore.

ip link add dev wg0 type wireguard
Error: Unknown device type.

After doing a modprobe it states the following error:

# modprobe wireguard
modprobe: FATAL: Module wireguard not found in directory /lib/modules/5.0.4-2004

Checking dkms states it the wireguard module is active

# dkms status
wireguard, 1.0.20200520, 5.3.0-1022-azure, x86_64: built

To fix this issue rebuild and install the module into the new kernel.
Make sure you install the linux-headers for your kernel!

# apt install linux-headers

Rebuilding the module (make sure to note the applicable wireguard version! This is returned by dkms status) In the example verison 1.0.20200520 is used:

# dkms status
# dkms build wireguard/1.0.20200520
# dims install wireguard/1.0.20200520
# modprobe wireguard
# wg-quick up wg0

Thats it!

3 thoughts on “Wireguard: Attempting to Install and Configure Wireguard Fails with “Unknown device type” and “FATAL: Module wireguard not found in directory”

  1. Do you have an idea after this error:

    root@raspberrypi:~# dkms status
    wireguard, 1.0.20200908, 5.4.51+, armv7l: installed
    wireguard, 1.0.20200908, 5.4.51-v7+, armv7l: installed
    wireguard, 1.0.20200908, 5.4.51-v7l+, armv7l: installed
    root@raspberrypi:~# dkms build wireguard/10.0.20200908
    Error! Could not find module source directory.
    Directory: /usr/src/wireguard-10.0.20200908 does not exist.
    root@raspberrypi:~# dkms build wireguard/1.0.20200908
    Error! echo
    Your kernel headers for kernel 5.4.65-v7l+ cannot be found at
    /lib/modules/5.4.65-v7l+/build or /lib/modules/5.4.65-v7l+/source.

    1. Hi Maarten,

      It seems you need to install linux-headers as these are needed to compile the module.

Leave a Reply

Your email address will not be published.