How to convince systemd-resolved to *not* use an interface?

I have a laptop with two interfaces, once on my home network, and another on an experimental mesh network. The laptop current is getting its DNS servers from the experimental mesh, which are bogus, and is ignoring my home network’s DNS servers.

How to I configure systemd-resolvd to ignore any efforts by the mesh network to inject bogus DNS server info and pick up my home network’s DNS servers? Is there a way to manually configure systemd-resolved or should I just rip it out?

resolvectl status:
Global
Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (enp2s0)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 10.21.75.105 <<-- BOGUS MAYBE (DNS for 10-net only)
DNS Domain: local.mesh
Default Route: yes <<--BOGUS

Link 3 (wlp1s0)
Current Scopes: LLMNR/IPv4 LLMNR/IPv6
Protocols: -DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
Default Route: no <<--BOGUS

My routing table looks like this, my home network is actuallly the default route:

Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlp1s0
10.0.0.0 10.21.75.105 255.0.0.0 UG 0 0 0 enp2s0
10.21.75.104 0.0.0.0 255.255.255.248 U 0 0 0 enp2s0
44.32.112.0 10.21.75.105 255.255.240.0 UG 0 0 0 enp2s0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp1s0

DNS information is uploaded to systemd-resolved by NetworkManager, so all you need to do is to turn off obtaining DNS from that interface:

p/s: “Use this connection only for resources on its network” is useful to prevent your system from picking up a default route from the target network.

You can also set these parameters via nmcli connection edit, as ipv4.ignore-auto-dns and ipv4.never-default (v4 → v6 for v6 networks).

Unfortunately for various sad reasons I am using LXDE, which has no network configuration widgets.

The real problem was the default route. Ultimately the solution to fix both routing and DNS was to use dhcp-options to stop the dnsmasq daemon on the problematic network from handing out a default route and a DNS server. Unfortunately, that is default dnsmasq behavior which fails in the case where a laptop is connected to two LANs and one of the LANs does not reach the internet.

For good measure, on the laptop, I set “dns=none” in NetworkManager.conf, added a real resolv.conf file and disabled systemd-resolved.

I’m glad you solved your issue, albeit a bit heavy handed. Here are a few recs for next time:

nmcli is a CLI that you can use to configure, and I’ve already included the commands in the previous post.

If you need an UI, nm-connection-editor is a standalone Gtk app that you can use, as well as network-manager-applet provides a nice tray icon/applet to configure connections.