Skip to content

systemd-resolved considers all DNS servers equivalent #21174

Closed

Description

@rfried-nrl

systemd version the issue has been seen with

systemd 247 (247.3-3ubuntu3.6)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid

Used distribution

Ubuntu Server 21.04

Linux kernel version used (uname -a)
Linux mclaren 5.11.0-38-generic #42-Ubuntu SMP Fri Sep 24 14:03:54 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

CPU architecture issue was seen on

X86_64

Expected behaviour you didn't see

DNS Query being sent to nameservers

Unexpected behaviour you saw

dns resolve just skips few nameservers

Steps to reproduce the problem
DHCP provides 3 name-servers to the machine:
nameserver 72.25.1.128
nameserver 172.25.1.80
nameserver 8.8.8.8
Everything works as expected, but after a while. it could be day, or few hours, the first two nameservers stops working.
Placing TCP dump, shows that the systemd-resolve doesn't even issue a DNS resolve query to them.
Restarting systemd-resolve solves the problem.

The following message appears on the journal from time to time:

Oct 28 21:20:12 mclaren systemd-resolved[3667001]: Grace period over, resuming full feature set (UDP+EDNS0) for DNS server 172.25.1.128.
Oct 28 21:20:12 mclaren systemd-resolved[3667001]: Using degraded feature set UDP instead of UDP+EDNS0 for DNS server 172.25.1.128.

Additional program output to the terminal or log subsystem illustrating the issue

DNS query when bug is produced ( as captured by TCPdump)

20:54:09.798111 IP localhost.51919 > localhost.domain: 62398+ A? gerrit.neureality.corp. (40)
20:54:09.798138 IP localhost.51919 > localhost.domain: 16037+ AAAA? gerrit.neureality.corp. (40)
20:54:09.798401 IP mclaren.55150 > dns.google.domain: 50562+ [1au] A? gerrit.neureality.corp. (51)
20:54:09.798505 IP mclaren.40632 > dns.google.domain: 61041+ [1au] AAAA? gerrit.neureality.corp. (51)
20:54:09.860327 IP dns.google.domain > mclaren.40632: 61041 NXDomain 0/1/1 (126)
20:54:09.860410 IP mclaren.40632 > dns.google.domain: 61041+ AAAA? gerrit.neureality.corp. (40)
20:54:09.870888 IP dns.google.domain > mclaren.55150: 50562 NXDomain 0/1/1 (126)
20:54:09.870934 IP mclaren.55150 > dns.google.domain: 50562+ A? gerrit.neureality.corp. (40)
20:54:09.918640 IP dns.google.domain > mclaren.40632: 61041 NXDomain 0/1/0 (115)
20:54:09.918736 IP localhost.domain > localhost.51919: 16037 NXDomain 0/0/0 (40)
20:54:09.941180 IP dns.google.domain > mclaren.55150: 50562 NXDomain 0/1/0 (115)
20:54:09.941247 IP localhost.domain > localhost.51919: 62398 NXDomain 0/0/0 (40)
20:54:09.941333 IP localhost.40964 > localhost.domain: 35538+ A? gerrit. (24)
20:54:09.941344 IP localhost.40964 > localhost.domain: 726+ AAAA? gerrit. (24)
20:54:09.941382 IP localhost.domain > localhost.40964: 35538 ServFail 0/0/0 (24)
20:54:09.941421 IP localhost.domain > localhost.40964: 726 ServFail 0/0/0 (24)
20:54:09.941440 IP localhost.40964 > localhost.domain: 35538+ A? gerrit. (24)
20:54:09.941448 IP localhost.40964 > localhost.domain: 726+ AAAA? gerrit. (24)
20:54:09.941478 IP localhost.domain > localhost.40964: 35538 ServFail 0/0/0 (24)
20:54:09.941514 IP localhost.domain > localhost.40964: 726 ServFail 0/0/0 (24)

Same DNS query after systemd-resolve is restarted:

20:56:01.303349 IP localhost.38987 > localhost.domain: 32276+ A? gerrit.neureality.corp. (40)
20:56:01.303369 IP localhost.38987 > localhost.domain: 20509+ AAAA? gerrit.neureality.corp. (40)
20:56:01.303747 IP mclaren.48188 > ip-172-25-1-128.eu-central-1.compute.internal.domain: 2055+ [1au] A? gerrit.neureality.corp. (51)
20:56:01.303860 IP mclaren.36125 > ip-172-25-1-128.eu-central-1.compute.internal.domain: 65195+ [1au] AAAA? gerrit.neureality.corp. (51)
20:56:01.303927 IP localhost.47310 > localhost.domain: 31712+ PTR? 128.1.25.172.in-addr.arpa. (43)
20:56:01.304037 IP mclaren.60087 > ip-172-25-1-128.eu-central-1.compute.internal.domain: 24227+ [1au] PTR? 128.1.25.172.in-addr.arpa. (54)
20:56:01.366713 IP ip-172-25-1-128.eu-central-1.compute.internal.domain > mclaren.36125: 65195 0/1/0 (127)
20:56:01.366837 IP mclaren.36125 > ip-172-25-1-128.eu-central-1.compute.internal.domain: 37353+ AAAA? gerrit.neureality.corp. (40)
20:56:01.367453 IP ip-172-25-1-128.eu-central-1.compute.internal.domain > mclaren.48188: 2055 1/0/0 A 172.25.1.229 (56)
20:56:01.451829 IP ip-172-25-1-128.eu-central-1.compute.internal.domain > mclaren.36125: 37353 0/1/0 (127)
20:56:01.451895 IP localhost.domain > localhost.38987: 20509 0/0/0 (40)
20:56:01.512352 IP localhost.35394 > localhost.domain: 13276+ PTR? 229.1.25.172.in-addr.arpa. (43)
20:56:01.512446 IP mclaren.60534 > ip-172-25-1-128.eu-central-1.compute.internal.domain: 4956+ PTR? 229.1.25.172.in-addr.arpa. (43)
20:56:01.575512 IP ip-172-25-1-128.eu-central-1.compute.internal.domain > mclaren.60534: 4956 1/0/0 PTR ip-172-25-1-229.eu-central-1.compute.internal. (102)
20:56:01.575598 IP localhost.domain > localhost.35394: 13276 1/0/0 PTR ip-172-25-1-229.eu-central-1.compute.internal. (102)
20:56:02.512355 IP localhost.42807 > localhost.domain: 32260+ PTR? 229.1.25.172.in-addr.arpa. (43)
20:56:02.512625 IP localhost.domain > localhost.42807: 32260 1/0/0 PTR ip-172-25-1-229.eu-central-1.compute.internal. (102)
20:56:03.513385 IP localhost.43607 > localhost.domain: 59001+ PTR? 229.1.25.172.in-addr.arpa. (43)
20:56:03.513498 IP localhost.domain > localhost.43607: 59001 1/0/0 PTR ip-172-25-1-229.eu-central-1.compute.internal. (102)
20:56:04.515308 IP localhost.54797 > localhost.domain: 32068+ PTR? 229.1.25.172.in-addr.arpa. (43)
20:56:04.515397 IP localhost.domain > localhost.54797: 32068 1/0/0 PTR ip-172-25-1-229.eu-central-1.compute.internal. (102)
20:56:05.515839 IP localhost.32930 > localhost.domain: 43351+ PTR? 229.1.25.172.in-addr.arpa. (43)

Activity

  1. gudvinr commented on Oct 29, 2021

    @gudvinr

    Looks like same issue as #21123

  2. poettering commented on Nov 2, 2021

    @poettering
    Member

    resolved sticks to the DNS server that works. It starts with the first listed, but whenever there's a failure it switches to next. But it sticks to each DNS server as long as it works, and doesn't bother with any other DNS server then. i.e. it remember the stat between requests and doesn#t start again from the tpo.

    I guess you are under the impression it would start from the first listed DNS server on each request? That's not how this works though, we maintain state and stick to what works, and don't retry servers that failed once already.

  3. offsides commented on Dec 22, 2021

    @offsides

    I guess you are under the impression it would start from the first listed DNS server on each request? That's not how this works though, we maintain state and stick to what works, and don't retry servers that failed once already.

    That's an extremely narrow definition of "what works". I maintain a local DNS server for my home network. This is 99% reliable, and only doesn't work if the server goes down due to a power failure or maybe is being rebooted. In that case, I want my devices to resolve via my router, and if it's not behaving I want them to query the DNS servers provided by my Internet provider, in that order. This works 100% of the time for all other devices, as they follow the rule of "query the first DNS server, and go down the line if it doesn't answer." My laptop, now that I upgraded from F32 to F34 using systemd-resolved, does not. For reasons that are irrelevant to this issue, my wireless NIC occasionally freezes for a couple seconds, causing brief network failures. When this happens during a DNS query, resolved marks my internal DNS as failed, and queries the router and eventually ends up querying the external DNS servers. Which works fine for Internet browsing, but completely breaks any ability to lookup other devices on my network. BUT THIS ONLY HAPPENS FOR THE SYSTEM USING RESOLVED.

    In other words, because systemd-resolved insists on doing things using a very narrow definition and action plan that doesn't match how everybody else does the same type of thing, it causes DNS resolution to fail for devices that use it under highly predictable and reasonably normal circumstances. And the only permanent solution is to either change the global network config (DHCP DNS servers) such that it potentially breaks under other, difference conditions, or to stop using systemd-resolved and have to manually configure the system to use an alternative system. I know there's a ticket that's been open for multiple years asking for a config option to not mark DNS servers failed and continue to use them in order, and I'm not sure why it hasn't been implemented (or even seriously considered, from what I remember reading), but I'll ask for it here as well. Just because the current implementation of systemd-resolved meets spec and works for many situations doesn't mean that it shouldn't support mimicking the old way - especially when the old way is still used by the vast majority of Internet users.

    Is there any fundamental technical reason why systemd-resolved CANNOT support a runtime configuration option to continue querying DNS servers in configured order even if one fails to respond? Or even have some sort of failure timeout whereby it marks it failed for a period of time (5 minutes? 15 minutes? user configurable?) before trying it again? Or heck, even a resolvectl option to force it to reset the query order so that someone can manually reset it without having to restart the service would be an improvement. There's more than one way to do things, and the more narrow your definition of something working the more likely you are to break under even the most minuscule of deviations from the norm.

  4. jonesmz commented on Jan 29, 2022

    @jonesmz

    I use systemd-resolved in an environment where I have a samba domain controller as the (primary) DNS server.

    If systemd-resolved decides that it doesn't like the domain controller (it rebooted, for example) it switches to the fallback DNS server.

    This means that the machine using systemd-resolved can no longer use DNS to query for important active directory resources, and eventually any cached user credentials expire and users can no longer log into the machine.

    Systemd-resolved should not be "sticking to what worked" in those situations, as not all DNS servers are equal, which i think it obvious based on the hierarchical nature of DNS in general.

    It's fine if systemd-resolved wants to be "sticky" for some period of time. But it should absolutely be re-trying DNS servers that failed recently and try to go back to the first-listed server, and not stay with the fallback server forever.

  5. pemensik commented on Oct 19, 2022

    @pemensik
    Contributor

    I think such config should have a different configuration a bit. First two nameservers are clearly offering more domains than the fallback dns.google server. I think the problem is DHCP offers 3 servers for the network, but only first two offer the full service. Ideally there should be way to tell from DHCP that the two first handle list of internal domains. resolved is able to direct subdomains to limited set of servers, so it could direct internal names always to internal servers only.

    Reliance on the order of servers is more a workaround for such situation. I think the problem is resolved handles list of domains from the connection/interface and list of all servers as bundled set. It should have a way to tell the 8.8.8.8 server is just fallback for the connectivity, not handling full domains set specified by domain search dhcp property.

  6. pemensik commented on Oct 19, 2022

    @pemensik
    Contributor

    But since requests to keep the order of servers seems to be common request, it should have a configurable way to try the servers in order of specification. Of course it should retry after some time and try to switch back to original configuration if leading servers were broken, but are not anymore. I don't think it needs to be default behaviour, it would be useful to enable.

  7. added
    downstream/rhel
    on Oct 19, 2022
  8. pemensik commented on Oct 19, 2022

    @pemensik
    Contributor

    I think the core of the problem might be solved by separate list of internal domain names mapping to internal servers, which is defined in RFC Improved Recursive DNS Server Selection for Multi-Interfaced Nodes. But I don't think such thing is implemented in Network Manager or any other similar network configuration interface. It should provide a way to specify mapping of local network names to local network servers, which is the primary reason they want the first two servers preferred.

  9. pemensik commented on Oct 19, 2022

    @pemensik
    Contributor

    It seems to be issue #25020 describes very similar expectation just in other words.

  10. schanzen commented on Oct 20, 2022

    @schanzen

    It seems to be issue #25020 describes very similar expectation just in other words.

    Yes, closed now as duplicate of this old bug #5755. In fact I struggle to understand how this behavior is compatible with the (very common) split horizon deployment or simply people running their pihole with a safe quad 9 fallback or some such.
    Without even noticing their pihole is bypassed because, idk, somebody accidentally pulled the plug briefly.

    I have yet to see a corporate network where you don't get local IP addresses internally and public externally as authoritative answers from the same name by nature of DNS precendence.
    A simple even short outage of the local DNS server will cause routes to go through the public network which is not only possibly disruptive to the users (sometimes there is no route to the external IP), but also almost impossible to debug for the admins.
    A setting that emulates resolv.conf behavior would be great as it is the simplest solution.

  11. changed the title [-]systemd-resolved stops quering local DNS servers[/-] [+]systemd-resolved considers all DNS servers equivalent[/+] on Mar 5, 2024
  12. poettering commented on Mar 5, 2024

    @poettering
    Member

    Duplicate of #5755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    downstream/rhelduplicateresolve

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions