Score:0

Failed to resolve interface "tun": No such device

cn flag

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

ru flag
Include the full error output and any other output related to it into your question as an edit, there's likely other information we still need to help with this in the error output.
Kurosh Ghanizadeh avatar
cn flag
@ThomasWard I've added the full error, but I'm not familiar with these things, so I'll be glad to know what information you need.
David Delagneau avatar
br flag
maybe related, I disabled DNS wireguard file configutation https://www.reddit.com/r/WireGuard/comments/yg13kl/problem_with_wireguardtun_module_after_updating/
Score:2
mr flag

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.

Score:1
cn flag

Running sudo apt purge resolvconf and rebooting fixed the issue.

taiyodayo avatar
cn flag
This worked for me! Fresh Ubuntu 22.04 updated to 22.10, wg0 stopped working with exact same error as the original poster. Thanks!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.