/errors/wireguard/rtnetlink-answers-operation-not-supported
wg-quick: RTNETLINK answers: Operation not supported (ip link add wg0 type wireguard)
- tool
- WireGuard
- exit code
- 2
- versions
- Linux 5.6+ (WireGuard in mainline), wireguard-tools 1.0
- os
- linux
RTNETLINK answers: Operation not supported right after [#] ip link add wg0 type wireguard means the kernel does not know the wireguard interface type: the WireGuard module is not loaded and cannot be loaded. Load it with sudo modprobe wireguard; if that fails, the running kernel has no WireGuard support (kernel older than 5.6 without the DKMS module, a kernel upgraded without a reboot, or a container/VPS that shares a host kernel). The userspace implementation wireguard-go is the fallback where no module is possible.
What it looks like
[#] ip link add wg0 type wireguard
RTNETLINK answers: Operation not supportedWith recent kernels and iproute2, which pass extended error messages, the same failure is printed as Error: Unknown device type. Both come from ip link add, not from WireGuard's own tools; wg-quick then stops with the exit status of ip (2).
Diagnose
uname -r # running kernel (5.6+ has WireGuard built in or as a module)
sudo modprobe wireguard && lsmod | grep wireguard
modinfo wireguard | head -3 # is a module available for this kernel?
ls /lib/modules/$(uname -r)/ >/dev/null || echo "modules for the running kernel are missing: reboot"modprobe: FATAL: Module wireguard not found in directory /lib/modules/... after a kernel update usually means the new kernel is installed but the old one is still running: reboot.
Fixes
| Situation | Fix |
|---|---|
| Kernel 5.6 or newer, module not loaded | sudo modprobe wireguard; add wireguard to /etc/modules-load.d/ for boot |
| Kernel upgraded, not rebooted | Reboot into the new kernel |
| Kernel older than 5.6 | Install wireguard-dkms and the headers for the running kernel, or upgrade the kernel |
| Container (Docker, LXC) | Load the module on the host; run the container with --cap-add=NET_ADMIN |
| OpenVZ or another shared-kernel VPS | Install wireguard-go; wg-quick uses it when the kernel module is missing |
| Secure Boot blocks a DKMS module | Enrol the DKMS signing key (mokutil) or use a distribution kernel with WireGuard built in |
When ip link add fails and the wireguard-go binary is on the PATH, wg-quick prints [!] Missing WireGuard kernel module. Falling back to slow userspace implementation. and continues with the userspace implementation. Its throughput is lower than the kernel module's, but the configuration is the same.