Resolv.conf empty after disconnecting from wireguard

I use nmcli to control my wireguard connections.
After disconnecting from my wireguard VPN I get the following when I run cat /etc/resolv.conf:

# Generated by NetworkManager

It’s empty. What can I do ?

reconnect to your network (disconnect and connect again)

That’s not a good solution.
Mainly because in a country with internet censorship I recurrently need to connect to and disconnect from VPN.

Well, I don’t know Wireguard and haven’t worked with it yet, but I DO know in the CLI setup there is a preup and postdown hook (I don’t know where to find this in NetworkManager, sorry.)

Use that to make a temporary copy of your resolv.conf somewhere (Might as well be in /tmp/ and restore/copy it back on disconnect…

(Yeah, this is probably not the correct way to do it, but as I said, I haven’t worked with Wireguard yet.)

I added the following to /etc/NetworkManager/NetworkManager.conf:


I don’t why. But it worked. :joy:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.