5

I'm trying to use wireguard, but when I try to use it with wg-quick up I get the error.

wg-quick up test
Warning: `/etc/wireguard/test.conf' is world accessible
[#] ip link add test type wireguard
[#] wg setconf test /dev/fd/63
[#] ip -4 address add 172.16.0.29/32 dev test
[#] ip -6 address add fd::29/128 dev test
[#] ip link set mtu 1395 up dev test
[#] resolvconf -a tun.test -m 0 -x
Failed to resolve interface "tun": No such device
[#] ip link delete dev test

As I checked other's questions I found out that I don't have 'tun.ko.gz' (`find /lib/modules/ -iname 'tun.ko.gz'` returns nothing), so I can't load the 'tun'.
$ uname -r
> 5.11.0-40-generic

I'm using Ubuntu 20.04

2 Answers2

9

Running sudo apt purge resolvconf and rebooting fixed the issue.

2

I found good working solution using PostUp in wireguard config file

instead of using:

DNS = <ip>

Try this under [Interface] instead:

PostUp = resolvectl dns %i <ip>

(if you already have a PostUp, just add another one)

That will configure the wireguard interface to use the specified <ip> as the DNS server for that interface. You can also add a domain search if you want:

PostUp = resolvectl dns %i <ip>; resolvectl domain %i \~domain

(replace "domain" with the actual domain suffix you want searched, but keep the \~)

There is no need in PostDown, because the wireguard interface (to which this config is attached) will be gone then.

Source

Just removing DNS=*.*.*.* may be ok for some people, because you will be able to connect to wireguard without errors and you will be able to use internet as regular VPN user. But in my case if I remove DNS line I will not be able to connect to other peers which is crucial for me. PostUp is a complete fix without losing anything.