0

I have a local DNS resolver configuration and I am not sure why my DNS resolvers are switching. Here is my configuration

#cat /etc/systemd/resolved.conf

[Resolve]
DNS=W.X.Y.Z
#FallbackDNS=
Domains=example.com
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=no-negative
#DNSStubListener=yes
#ReadEtcHosts=yes

#cat /etc/resolve.conf

nameserver 127.0.0.53
options edns0 trust-ad
 search example.com test.xxnet.com

But when I see #systemd-resolve --status

Current DNS Server: A.B.C.D
     DNS Servers: W.X.Y.Z
                  A.B.C.D
      DNS Domain: example.com
                  test.xxnet.com

I have 3 questions here:

  1. why DNS servers are switching even though I used timeout 5 in /etc/resolv.conf?
  2. where does A.B.C.D come from?
  3. how to stop switching or only use W.X.Y.Z as a DNS resolver?

Thanks for the support.

1 Answer 1

0

From man systemd-resolved, emphasis mine:

The DNS servers contacted are determined from

the global settings in /etc/systemd/resolved.conf,

the per-link static settings in /etc/systemd/network/*.network files (in case systemd-networkd.service(8) is used),

the per-link dynamic settings received over DHCP,

information provided via resolvectl(1),

and any DNS server information made available by other system services.

The resulting list of DNS servers to use is a combination of all these sources. So probably your DHCP server specifies A.B.C.D as the DNS server to use, and test.xxnet.com as the domain to use. That makes A.B.C.D as a connection-specific DNS server, which also makes it the preferred DNS server for that connection.

That also means *.example.com names would be queried from both A.B.C.D and W.X.Y.Z, but *.test.xxnet.com names would be queried from A.B.C.D only, since the search domain test.xxnet.com was (probably) also supplied from the connection-specific DNS configuration (received by DHCP).

You might have to tell your DHCP client to ignore the DNS configuration supplied by the DHCP server.

How to do that depends on two things:

  • which DHCP client are you using? (dhclient and dhcpcd are common)

  • are you configuring the DHCP client directly, or is it configured by NetworkManager or some other network configuration management system?

Please edit your question to supply this information, and I'll update this answer accordingly if I can.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.