wg-quick errors on Linux: resolvconf: command not found and others

resolvconf: command not found means the file has a DNS line, and the system has no resolvconf program for wg-quick to set it with: install one, link it to resolvectl, or set DNS another way. “wg0 already exists” means the tunnel is already up: take it down first. RTNETLINK answers: Operation not supported is a kernel without WireGuard, and Operation not permitted is missing rights, most often in a container.

Updated

WireGuard config check: fields, mistakes and a QR code

Veli on Linux doesn't use wg-quick. Veli connects WireGuard and AmneziaWG with a client of its own, so on Linux it needs neither wg-quick nor the kernel module nor resolvconf.

Download Veli for free
On this page

How to read what wg-quick prints

wg-quick is a script that runs one command after another and prints each with [#] in front. The first command that fails stops it. Right after that it removes the interface, so the last lines are often [#] ip link delete dev wg0: that is cleaning up, not the error. The error is the line before it, and the [#] line above says which command gave it.

  • resolvconf: command not found

    CauseDNS in the file, no resolvconf in the system

    What to doSee the next section

  • wg-quick: `wg0' already exists

    CauseThe interface is up already, often by the service at boot

    What to dosudo wg-quick down wg0, then up

  • wg-quick: `wg0' is not a WireGuard interface

    Causedown for a tunnel that isn't up, or the name belongs to another program

    What to dosudo wg show interfaces lists the real ones

  • Error: Unknown device type. or RTNETLINK answers: Operation not supported after ip link add

    CauseThe running kernel has no WireGuard

    What to doLoad the module, reboot after a kernel update, or wireguard-go

  • RTNETLINK answers: Operation not supported after ip -6 address add

    CauseIPv6 is off in the kernel (ipv6.disable=1)

    What to doRemove the IPv6 address from Address, or turn IPv6 on

  • Error: ipv6: IPv6 is disabled on this device. or RTNETLINK answers: Permission denied

    CauseIPv6 is switched off with sysctl (disable_ipv6=1)

    What to doThe same: remove the IPv6 address or turn IPv6 on

  • RTNETLINK answers: Operation not permitted

    CauseNo right to change the network: a container, or no root

    What to doSee “Operation not permitted” below

  • RTNETLINK answers: File exists after ip route add

    CauseAnother interface already has a route to exactly this network

    What to doNarrow AllowedIPs, or take the other tunnel down

  • RTNETLINK answers: Address already in use after ip link set

    CauseListenPort is taken by another program or tunnel

    What to doAnother port, or sudo ss -ulnp to see who holds it

  • Temporary failure in name resolution, then Trying again in 1.00 seconds...

    CauseThe name in Endpoint doesn't resolve yet: no network or DNS

    What to doWait for the network, or put the IP into Endpoint

  • iptables-restore: command not found

    CauseFull tunnel, and neither nftables nor iptables is installed

    What to dosudo apt install nftables

  • permission denied on key with net.ipv4.conf.all.src_valid_mark

    CauseFull tunnel in a container that may not change sysctl

    What to doStart it with --sysctl net.ipv4.conf.all.src_valid_mark=1

  • wg-quick: The config file must be a valid interface name, followed by .conf

    CauseThe file's name is longer than 15 characters or has spaces or brackets

    What to doRename it, for example wg0.conf

resolvconf: command not found

WireGuard itself knows nothing of DNS. For a DNS line wg-quick runs resolvconf -a wg0 -m 0 -x, and the program isn't part of the wireguard-tools package. What to install depends on who runs DNS on the system, and the first command below tells that.

On Ubuntu 22.04 the usual cause is that resolvectl is there and its second name isn't: the file resolvconf came into the systemd-resolved package later, in 24.04 it is included. One program answers to both names, its manual says so, so a link is enough.

Linux: Terminal
systemctl is-active systemd-resolved

active: take the link from the next command. Anything else: install a resolvconf of its own.

systemd-resolved is active (Ubuntu and others)
sudo ln -s "$(command -v resolvectl)" /usr/local/bin/resolvconf

Makes resolvectl answer to the name wg-quick calls. On Arch the package systemd-resolvconf does the same.

Debian and Ubuntu without systemd-resolved
sudo apt install openresolv

On Arch: sudo pacman -S openresolv, on Alpine: sudo apk add openresolv.

Without resolvconf: in [Interface], in place of the DNS line
PostUp = resolvectl dns %i 1.1.1.1; resolvectl domain %i "~."

For systems with systemd-resolved. %i is the interface, ~. sends all names to this DNS.

  • Just delete the DNS line and the tunnel comes up, but names go to the DNS the system already had, often the provider's: that is a DNS leak.
  • Failed to set DNS configuration and resolve1 in the rest of the line: the link is there, systemd-resolved isn't running. sudo systemctl enable --now systemd-resolved.
  • signature mismatch: /etc/resolv.conf comes from openresolv: another program rewrote the file after it. sudo resolvconf -u writes it anew; then decide which of the two should manage DNS.
  • Failed to resolve interface "tun.wg0": a leftover /etc/resolvconf/interface-order from the old resolvconf package makes wg-quick put tun. in front. Update wireguard-tools or remove the old package with sudo apt purge resolvconf.

wg-quick: `wg0' already exists

Before doing anything wg-quick checks whether an interface with this name is there, and stops if it is. Most often the tunnel was started at boot by wg-quick@wg0, or is still up from last time. To apply an edited file without dropping connections there is syncconf; it doesn't change addresses, DNS or routes, for those restart the tunnel.

Linux: Terminal
sudo wg-quick down wg0 &&
  sudo wg-quick up wg0

Restart by hand. If the service manages the tunnel, use sudo systemctl restart wg-quick@wg0 and not both.

Linux: Terminal (bash)
sudo bash -c 'wg syncconf wg0 <(wg-quick strip wg0)'

Applies keys, peers, AllowedIPs and endpoints to the running tunnel. sudo systemctl reload wg-quick@wg0 does the same.

Linux: Terminal
ip -d link show wg0

If down says it isn't a WireGuard interface, this shows what it is and which type. A name taken by another program is best left alone: rename your file.

RTNETLINK answers: Operation not supported

The line above is [#] ip link add dev wg0 type wireguard: the kernel was asked for an interface of a type it doesn't know. Newer systems word it as Error: Unknown device type. WireGuard has been part of the kernel since 5.6; on an older kernel it is a separate module. The other common reason is an update: the kernel's package was replaced, the computer wasn't restarted, and the modules of the running version are gone.

The same failure gives Unable to access interface: Protocol not supported in wg show wg0.

Linux: Terminal
uname -r; ls /lib/modules; sudo modprobe wireguard

The running version has to be in the list. Not there: reboot. There, but modprobe doesn't find wireguard: the kernel was built without it, or is older than 5.6.

Debian and Ubuntu with an old kernel: Terminal
sudo apt install wireguard

Brings the module together with the tools where the kernel has none of its own. After that, sudo modprobe wireguard.

  • Virtual servers without their own kernel (OpenVZ, LXC): the module must be loaded on the host. You can't do that from inside, so ask the hosting company or take a KVM server.
  • wireguard-go. If the module isn't there but wireguard-go is installed, wg-quick takes it by itself and says [!] Missing WireGuard kernel module. Falling back to slow userspace implementation. It needs /dev/net/tun.

RTNETLINK answers: Operation not permitted

Creating an interface needs the right to manage the network. wg-quick asks for sudo by itself, so on an ordinary computer you rarely see this; in a container, root inside is not root for the network.

Docker
docker run --cap-add NET_ADMIN --sysctl net.ipv4.conf.all.src_valid_mark=1 IMAGE

The right to manage the container's network, and the sysctl a full tunnel needs. The module itself is taken from the host. IMAGE is your image.

  • LXC and Proxmox: load wireguard on the host; for wireguard-go let the container use /dev/net/tun.
  • Unable to access interface: Operation not permitted from wg show is simpler: run it with sudo.

If that isn't it

If the tunnel comes up at your hand and not at boot, look at the service's log. Its unit waits for the network and repeats failed name lookups without end, so with no DNS at boot it keeps starting. If the last line is Configuration parsing error, the trouble is in the file: see the guide on config errors.

Linux: Terminal
journalctl -u wg-quick@wg0 -b --no-pager

What the service printed since the last boot, with the [#] lines.

Sources

How we write and check

In Veli

Veli on Linux doesn't use wg-quick

Veli connects WireGuard and AmneziaWG with a client of its own, so on Linux it needs neither wg-quick nor the kernel module nor resolvconf. It sets DNS through resolvectl where systemd-resolved runs, and otherwise writes /etc/resolv.conf and puts the old one back on disconnecting. The same .conf goes into Profiles → Add, as a file or as text.

What differs: PreUp, PostUp, PreDown and PostDown are not run, the app never executes commands from a config; a file has to have one [Peer] with an Endpoint and an IPv4 address in Address. That is a client's file. A server with wg-quick stays as it is.

FAQ

How do I fix resolvconf: command not found in WireGuard?

If systemd-resolved is active, link resolvectl to /usr/local/bin/resolvconf. If it isn't, install openresolv. Or replace the DNS line with PostUp.

Does WireGuard need resolvconf?

Only wg-quick, and only for a DNS line. A tunnel without DNS in the file comes up without it.

What does RTNETLINK answers: File exists mean in wg-quick?

The system already has a route to one of the AllowedIPs networks through another interface, for example a second tunnel with the same network.

How do I restart WireGuard on Linux?

sudo systemctl restart wg-quick@wg0 if it runs as a service, otherwise wg-quick down wg0 and wg-quick up wg0.

Why does wg-quick up remove the interface after an error?

It undoes what it had started so that nothing half-made stays. The cause is the line above the removal.

WireGuard on Linux without wg-quick

Veli is a free client for Windows, macOS, Linux and Android. It connects a WireGuard .conf by itself: no kernel module, no resolvconf, and DNS goes back when you disconnect.