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.