4

I have connected to an openconnect VPN like thing, and it has added a DNS server (& DNS domain) to my systemd-resolved, and they don't work, so using the internet is slowed down, because every new request has to wait for the timeout to the broken DNS server, before going to the working, originally configured DNS server (I presume).

How can I remove that DNS server from systemd-resolved?

$ systemd-resolve --status
Global
         DNS Servers: 10.127.201.221
                      10.63.101.221
                      172.25.2.253
          DNS Domain: blah1.example
                      example.com
          DNSSEC NTA: 10.in-addr.arpa
          ...

Ubuntu Linux 18.04. systemd v237

1

2 Answers 2

1

I second Ian D. Allen comment :

1- the resolvectl revert command does not remove DNS from Global section

2- one cannot obviously revert an interface, tun0 which is actually down

So the question remains open

Regards, Xavier

1
  • Please don’t post a new answer  just to say that another answer didn’t work for you. Jul 21, 2022 at 4:13
0

Systemd < v239

The command you are after should be:

systemd-resolve --interface=tun0 --revert

Where tun0 would be the interface to remove dns settings from:

--revert
       Revert the per-interface DNS configuration. This option must be combined with
       --interface= to indicate the network interface the DNS configuration shall be reverted
       on. If the DNS configuration is reverted all per-interface DNS setting are reset to
       their defaults, undoing all effects of --set-dns=, --set-domain=, --set-llmnr=,
       --set-mdns=, --set-dnssec=, --set-nta=. Note that when a network interface disappears
       all configuration is lost automatically, an explicit reverting is not necessary in
       that case.

Looks like these tools changed in systemd v239 (which was actually on my Bionic test machine).

Systemd >= v239

The above command should still be available on newer version of systemd, if not then try resolvectl's revert command. You will need the interface name of the link you want to reset. Ex:

sudo resolvectl revert tun0

From the resolvectl manual:

revert LINK

Revert the per-interface DNS configuration. If the DNS configuration is reverted all per-interface DNS setting are reset to their defaults, undoing all effects of dns, domain, llmnr, mdns, dnssec, dnsovertls, nta. Note that when a network interface disappears all configuration is lost automatically, an explicit reverting is not necessary in that case.

Since systemd-resolved associates DNS servers with network interfaces, this should drop the DNS servers it has learned about from that interface.

Systemd-resolved Notes

This behavior of systemd-resolved is mentioned in that manual entry as well, relevant excerpt:

Other multi-label names are routed to all local interfaces that have a DNS server configured, plus the globally configured DNS server if there is one.

I believe you want to tell systemd-resolved to forget about DNS servers for your tunnel interface, the resolvectl revert seems like the way to do this.

3
  • resolvectl is not a command on ubuntu 18.04. And apt-file can't find it. Aug 26, 2020 at 14:57
  • Looks like these tools were changed a bit in systemd v239. Updating answer.
    – 111---
    Aug 26, 2020 at 16:20
  • 4
    The DNS servers were added to the Global section. Removing them from the interface doesn't remove them from the Global section. How do you remove them from the Global section? Dec 19, 2020 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .