Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel module doesn't load on Fedora/CentOS #30

Closed
angristan opened this issue Aug 8, 2019 · 19 comments
Closed

Kernel module doesn't load on Fedora/CentOS #30

angristan opened this issue Aug 8, 2019 · 19 comments
Labels
info Provides information

Comments

@angristan
Copy link
Owner

[root@fedora-2gb-nbg1-1 ~]# systemctl status wg-quick@wg0.service
● wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0
   Loaded: loaded (/usr/lib/systemd/system/wg-quick@.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-08-08 22:30:55 CEST; 31s ago
     Docs: man:wg-quick(8)
           man:wg(8)
           https://www.wireguard.com/
           https://www.wireguard.com/quickstart/
           https://git.zx2c4.com/WireGuard/about/src/tools/man/wg-quick.8
           https://git.zx2c4.com/WireGuard/about/src/tools/man/wg.8
  Process: 1056 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=1/FAILURE)
 Main PID: 1056 (code=exited, status=1/FAILURE)

Aug 08 22:30:55 fedora-2gb-nbg1-1 systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
Aug 08 22:30:55 fedora-2gb-nbg1-1 wg-quick[1056]: [#] ip link add wg0 type wireguard
Aug 08 22:30:55 fedora-2gb-nbg1-1 wg-quick[1056]: Error: Unknown device type.
Aug 08 22:30:55 fedora-2gb-nbg1-1 wg-quick[1056]: Unable to access interface: Protocol not supported
Aug 08 22:30:55 fedora-2gb-nbg1-1 wg-quick[1056]: [#] ip link delete dev wg0
Aug 08 22:30:55 fedora-2gb-nbg1-1 wg-quick[1056]: Cannot find device "wg0"
Aug 08 22:30:55 fedora-2gb-nbg1-1 systemd[1]: wg-quick@wg0.service: Main process exited, code=exited, status=1/FAILURE
Aug 08 22:30:55 fedora-2gb-nbg1-1 systemd[1]: wg-quick@wg0.service: Failed with result 'exit-code'.
Aug 08 22:30:55 fedora-2gb-nbg1-1 systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.
[root@fedora-2gb-nbg1-1 ~]#
[root@fedora-2gb-nbg1-1 ~]# lsmod | grep wireguard
[root@fedora-2gb-nbg1-1 ~]#
[root@centos-2gb-nbg1-1 ~]# systemctl status wg-quick@wg0.service
● wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0
   Loaded: loaded (/usr/lib/systemd/system/wg-quick@.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-08-08 22:32:32 CEST; 13s ago
     Docs: man:wg-quick(8)
           man:wg(8)
           https://www.wireguard.com/
           https://www.wireguard.com/quickstart/
           https://git.zx2c4.com/WireGuard/about/src/tools/man/wg-quick.8
           https://git.zx2c4.com/WireGuard/about/src/tools/man/wg.8
 Main PID: 22401 (code=exited, status=1/FAILURE)

Aug 08 22:32:32 centos-2gb-nbg1-1 systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
Aug 08 22:32:32 centos-2gb-nbg1-1 wg-quick[22401]: [#] ip link add wg0 type wireguard
Aug 08 22:32:32 centos-2gb-nbg1-1 wg-quick[22401]: RTNETLINK answers: Operation not supported
Aug 08 22:32:32 centos-2gb-nbg1-1 wg-quick[22401]: Unable to access interface: Protocol not supported
Aug 08 22:32:32 centos-2gb-nbg1-1 wg-quick[22401]: [#] ip link delete dev wg0
Aug 08 22:32:32 centos-2gb-nbg1-1 wg-quick[22401]: Cannot find device "wg0"
Aug 08 22:32:32 centos-2gb-nbg1-1 systemd[1]: wg-quick@wg0.service: main process exited, code=exited, status=1/FAILURE
Aug 08 22:32:32 centos-2gb-nbg1-1 systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.
Aug 08 22:32:32 centos-2gb-nbg1-1 systemd[1]: Unit wg-quick@wg0.service entered failed state.
Aug 08 22:32:32 centos-2gb-nbg1-1 systemd[1]: wg-quick@wg0.service failed.
[root@centos-2gb-nbg1-1 ~]# 
[root@centos-2gb-nbg1-1 ~]# lsmod | grep wireguard
[root@centos-2gb-nbg1-1 ~]# 
@angristan angristan added bug Something isn't working help wanted Extra attention is needed labels Aug 8, 2019
@angristan
Copy link
Owner Author

I'm following https://www.wireguard.com/install/ so I wonder what could be missing.

@angristan
Copy link
Owner Author

Though:

[root@fedora-2gb-nbg1-1 ~]# dkms status
wireguard, 0.0.20190702: added

@angristan
Copy link
Owner Author

[root@centos-2gb-nbg1-1 ~]# dkms build wireguard/0.0.20190702
Error! echo
Your kernel headers for kernel 3.10.0-957.21.3.el7.x86_64 cannot be found at
/lib/modules/3.10.0-957.21.3.el7.x86_64/build or /lib/modules/3.10.0-957.21.3.el7.x86_64/source.

But the headers are here.

[root@centos-2gb-nbg1-1 ~]# yum install kernel-headers
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.wiuwiu.de
 * epel: mirror.wiuwiu.de
 * extras: mirror.eu.oneandone.net
 * updates: mirror.ratiokontakt.de
Package kernel-headers-3.10.0-957.27.2.el7.x86_64 already installed and latest version
Nothing to do

@angristan
Copy link
Owner Author

OK, the kernel and headers were not the same version:

[root@centos-2gb-nbg1-1 ~]# yum list | grep kernel-headers
kernel-headers.x86_64                   3.10.0-957.27.2.el7            @updates
[root@centos-2gb-nbg1-1 ~]# uname -a
Linux centos-2gb-nbg1-1 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@fedora-2gb-nbg1-1 ~]# dnf list | grep kernel-headers
kernel-headers.x86_64                                                  5.2.5-200.fc30                                             @updates
[root@fedora-2gb-nbg1-1 ~]#
[root@fedora-2gb-nbg1-1 ~]# uname -a
Linux fedora-2gb-nbg1-1 5.1.16-300.fc30.x86_64 #1 SMP Wed Jul 3 15:06:51 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

@angristan angristan added info Provides information and removed bug Something isn't working help wanted Extra attention is needed labels Aug 8, 2019
@angristan
Copy link
Owner Author

angristan commented Aug 8, 2019

SOLUTION: Running dnf update or yum update to get an up-to-date kernel and matching headers solves the issue.

@FreedomBen
Copy link

FreedomBen commented Sep 10, 2019

Having the same problem on Fedora 29, but my kernel headers and active kernel are the same. It seems to be failing because DKMS can't find the file:

[#] ip link add wg0-client-test type wireguard
Error: Unknown device type.
Unable to access interface: Protocol not supported
[#] ip link delete dev wg0-client-test
Cannot find device "wg0-client-test"
[ben@localhost ~]$ 
[ben@localhost ~]$ dkms status
Error! Could not locate dkms.conf file.
File: /var/lib/dkms/wireguard/0.0.20190702/source/dkms.conf does not exist.

Looks like it's trying to follow a broken symlink:

[ben@localhost ~]$ ll /var/lib/dkms/wireguard/0.0.20190702/source
lrwxrwxrwx. 1 root root 31 Jul  8 12:18 /var/lib/dkms/wireguard/0.0.20190702/source -> /usr/src/wireguard-0.0.20190702```

the symlink shouldn't be broken tho as the target exists:

```[ben@localhost ~]$ ll /usr/src/wireguard-0.0.20190905/
total 268K
drwxr-xr-x.  6 root root 4.0K Sep 10 09:28 .
drwxr-xr-x.  5 root root 4.0K Sep 10 09:28 ..
-rw-r--r--.  1 root root  11K Sep  9 14:44 allowedips.c
-rw-r--r--.  1 root root 1.8K Sep  9 14:44 allowedips.h
...

I manually removed the broken link and recreated it:
sudo ln -s /usr/src/wireguard-0.0.20190905/ /var/lib/dkms/wireguard/0.0.20190702/source

Now DKMS is happy. I rebuilt the modules:
sudo dkms autoinstall

Checked status:

wireguard, 0.0.20190702, 5.2.11-100.fc29.x86_64, x86_64: built
wireguard, 0.0.20190905, 5.2.11-100.fc29.x86_64, x86_64: installed

And it still doesn't work.

lsmod shows it isn't actually loaded. Loading it fails:

modprobe: ERROR: could not insert 'wireguard': Operation not permitted

No idea why it's failing.

@dan-eicher
Copy link

It broke for me on a dnf upgrade a couple days ago on Fedora 30

uname --kernel-release

5.2.13-200.fc30.x86_64

rpm -q kernel-headers

kernel-headers-5.2.13-200.fc30.x86_64

Did a:

sudo rm -r /var/lib/dkms/wireguard/0.0.20190702

sudo ln -s /usr/src/wireguard-0.0.20190905/ /var/lib/dkms/wireguard/0.0.20190905/source

sudo dkms autoinstall

and it works again.

...though this seems odd:

dkms status

wireguard, 0.0.20190905, 5.2.13-200.fc30.x86_64, x86_64: installed
wireguard, 0.0.20190905, 5.2.7-200.fc30.x86_64, x86_64: installed

@angristan
Copy link
Owner Author

Thanks for the feedback guys, although this seems related to Wireguard packaging on Fedora

@valentt
Copy link

valentt commented Nov 25, 2019

I have similar problem, but get different verbose output from modprobe:

# modprobe -vvv wireguard
modprobe: INFO: custom logging function 0x55cf4e172a20 registered
insmod /lib/modules/5.3.11-300.fc31.x86_64/kernel/net/wireguard.ko.xz  
modprobe: INFO: Failed to insert module '/lib/modules/5.3.11-300.fc31.x86_64/kernel/net/wireguard.ko.xz': Operation not permitted
modprobe: ERROR: could not insert 'wireguard': Operation not permitted
modprobe: INFO: context 0x55cf4eb9b4c0 released

Any ideas how to get wireguard module loaded? I removed it and rebuild it without success:

dkms remove -m wireguard -v 0.0.20191012 -k 5.3.11-300.fc31.x86_64
dkms install -m wireguard -v 0.0.20191012

Any help us much appreciated.

@angristan angristan pinned this issue Mar 4, 2020
@angristan
Copy link
Owner Author

dnf reinstall wireguard-dkms might help

@angristan angristan unpinned this issue Mar 21, 2020
angristan added a commit that referenced this issue Mar 21, 2020
@angristan
Copy link
Owner Author

I added a warning in the script that detects if the machine is running on Fedora or CentOS && wireguard not running and tells the user the command to update its machine. Should be better!

@Yakashimoto
Copy link

i have also big problem with CentOS 7, it dont work. i have some wireguards working fine with kernel wireguard, 0.0.20200215, 3.10.0-1062.12.1.el7.x86_64, x86_64: installed

but now i try on an another VPS, but it dont work...

Your kernel headers for kernel 3.10.0-1062.12.1.el7.x86_64 cannot be found at
/lib/modules/3.10.0-1062.12.1.el7.x86_64/build or /lib/modules/3.10.0-1062.12.1.el7.x86_64/source.

@chanyshev
Copy link

It also doesn't work. CentOS Linux release 7.8.2003 (Core)

[root@gw ~]# uname -a
Linux 3.10.0-1127.13.1.el7.x86_64
[root@gw ~]# yum list | grep kernel-headers
kernel-headers.x86_64                     3.10.0-1127.13.1.el7           @updates
[root@gw ~]# dkms status
wireguard, 1.0.20200623, 3.10.0-1127.13.1.el7.x86_64, x86_64: installed

@randshell
Copy link
Contributor

@Yakashimoto I was on that kernel version too and I had the same problem. Here is what I did #95 (comment)

@chanyshev thanks for the detailed information. Your output looks good, try to reboot. If it doesn't work paste the output of systemctl status wg-quick@wg0.service

@chanyshev
Copy link

@randomshell

journalctl -xe
-- Unit wg-quick@wg0.service has begun starting up.
Jul 08 03:32:34 gw.company.internal wg-quick[20217]: [#] ip link add wg0 type wireguard
Jul 08 03:32:34 gw.company.internal NetworkManager[740]: <info>  [1594193554.2405] manager: (wg0): new WireGuard device (/org/freedesktop/NetworkManager/Devices/10)
Jul 08 03:32:34 gw.company.internal wg-quick[20217]: [#] wg setconf wg0 /dev/fd/63
Jul 08 03:32:34 gw.company.internal wg-quick[20217]: Unable to parse IP address: `'
Jul 08 03:32:34 gw.company.internal wg-quick[20217]: Configuration parsing error
Jul 08 03:32:34 gw.company.internal wg-quick[20217]: [#] ip link delete dev wg0
Jul 08 03:32:34 gw.company.internal systemd[1]: wg-quick@wg0.service: main process exited, code=exited, status=1/FAILURE
Jul 08 03:32:34 gw.company.internal systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.
-- Subject: Unit wg-quick@wg0.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit wg-quick@wg0.service has failed.
--
-- The result is failed.
Jul 08 03:32:34 gw.company.internal systemd[1]: Unit wg-quick@wg0.service entered failed state.
Jul 08 03:32:34 gw.company.internal systemd[1]: wg-quick@wg0.service failed.
Jul 08 03:32:34 gw.company.internal polkitd[641]: Unregistered Authentication Agent for unix-process:20211:6658902 (system bus name :1.99, object path /org/freedesktop/PolicyKit1/AuthenticationA
Jul 08 03:32:36 gw.company.internal unix_chkpwd[20250]: password check failed for user (root)

@randshell
Copy link
Contributor

Jul 08 03:32:34 gw.company.internal wg-quick[20217]: Unable to parse IP address: `'
Jul 08 03:32:34 gw.company.internal wg-quick[20217]: Configuration parsing error

@chanyshev Open /etc/wireguard/wg0.conf and /etc/wireguard/params and check the IP addresses. If you aren't sure, I think you can delete the folder /etc/wireguard and run the script again.

@aliasmee
Copy link

some issue. not found wireguard module

@randshell
Copy link
Contributor

@aliasmee You can see the other comments for a solution. If it doesn't work for you provide the necessary info to debug please.

@joshghent
Copy link

Just wanted to chime in here and say that I resolved this on Amazon Linux 2 by running yum reinstall kernel and then restarted wireguard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info Provides information
Projects
None yet
Development

No branches or pull requests

9 participants