Skip to content

No new DNS Server selected after currently selected DNS server does no longer respond and concurrent DNS requests #17040

Closed

Description

@vicinus

systemd version the issue has been seen with

246

Used distribution

debian unstable

Expected behaviour you didn't see

If more then one DNS server are configured, and the currently selected DNS server does no longer respond to DNS requests, I would expect, that from the list of configured DNS server, excluding the DNS server who are in a failed state, the first is selected as the new currently selected DNS server

Unexpected behaviour you saw

With many cuncurrent DNS requests no new DNS server gets selected for more then one request. Instead a round-robin over all configured DNS server (even the failed one) is made.

Steps to reproduce the problem
I reproduced the issue with the following setup:

/etc/systemd/resolved.conf

[Resolve]
DNS=10.0.0.0 1.1.1.1 1.0.0.1 208.67.222.222

Configure iptables to route 10.0.0.0:53 to 8.8.8.8:53 (the problem does not occur if traffic is dropped on the local node, probably because resolved is somehow informed, that the dns packages were dropped and switches immediately instead of waiting for the timeout):

iptables -t nat -A OUTPUT -p udp -d 10.0.0.0 --dport 53 -j DNAT --to-destination 8.8.8.8:53

Restart systemd-resolved and ensure that 10.0.0.0 is selected:

systemctl restart systemd-resolved.service
resolvectl query googlebot.com
resolvectl status | grep "Current DNS Server:"

Remove iptables routing for 10.0.0.0:53:

iptables -t nat -F

Let the round-robin begin:

for i in $(seq 1 120); do ( resolvectl query $i.tine20.org &> /dev/null & ); echo $i; sleep 0.25; done

Attached the journal log from the run:
journal.txt

Activity

  1. StefanYohansson commented on Sep 14, 2020

    @StefanYohansson

    same as #5755

  2. vicinus commented on Sep 14, 2020

    @vicinus
    Author

    I think the issue is not the same as #5755 because in #5755 it is explained in the comments that both DNS servers are having timeouts and the switching occurs for that reason. In my case I have three perfectly fine DNS servers which as far as I can tell never did not reply to a request and one faulty one, which no longer replies to any requests. I would expect that one of the remaining three is chosen as the new 'Current DNS Server' and no round-robin over all (even the faults) DNS servers is made.

  3. StefanYohansson commented on Sep 14, 2020

    @StefanYohansson

    it is because that thread is biiig, but your behavior is discussed there too. Basically, the core of this discussion is to move into default resolv.conf that is what you are saying after fail one, try the next one.

    resolv.conf also has this option to round-robin (but it is a flag optional) that de-facto is what systemd implements. It is a huge thread but you can find every kind of opinion there.

  4. vicinus commented on Sep 14, 2020

    @vicinus
    Author

    I did read the hole thread prior to opening this bug report and looked over it again now and can not find any post where my behavior is discussed. Can you please point me to the corresponding post?

  5. diego-treitos commented on Sep 24, 2020

    @diego-treitos

    #5755 (comment)

    The primary DNS works just fine. I never see it offline. Actually, when systemd-resolved switches to 8.8.8.8 I can just test the resolving like this:

    So here we see that despite the primary DNS server being available, systemd-resolved is not using it.

  6. vicinus commented on Sep 24, 2020

    @vicinus
    Author

    If the meaning of your post is, that this is the same behavior as described in my report, then let me point out a simple differences:

    The primary DNS server in my issue does not answer any requests at all. My issue is that the faulty primary DNS server is still tried for DNS answers even if perfectly fine working DNS server are configured and answering DNS requests correctly!

    And for further clarification: my issue is not that no fallback is done to the first configured DNS server or that not all configured DNS servers are queried.

  7. diego-treitos commented on Sep 24, 2020

    @diego-treitos

    Maybe I am wrong on this but I think both issues are related in the sense that, at least in my experience (which I tested a while ago and might have changed) the nameservers seem to be rotated without reason.

    For what I understand, systemd-resolved selects an active nameserver and when this fails, it selects a different one in round robin. Although I believe it is true that the failed nameserver is not "marked" as failed and will be retried, the problem is that it keeps switching nameservers even if the active one works.

  8. vicinus commented on Sep 24, 2020

    @vicinus
    Author

    Sorry, if I misunderstood your intention. But I also think it is farfetched, that the problem I described, that after a correct start of switching the primary DNS Server no new primary DNS server gets permanently selected and the claimed switching of working DNS servers, are related, because both the trigger (primary DNS server failure in my case vs. unknown cause in switching working primary DNS server) and the triggered process (no new primary DNS server is permanently selected vs. a new primary DNS server is selected) do not match. Also, the problem of switching working primary DNS server is in the trigger, while the problem in not selecting permanently a new primary DNS server is in the triggered process. But I concede that this is only a clue and no proof.

  9. poettering commented on Oct 1, 2020

    @poettering
    Member

    Hmm, so let me get this right: when a ton of parallel requests all fail, each time we switch DNS servers, and you'd prefer we'd instead just switch once? i.e. we shouldn't round robin the DNS server unnecessarily: if the current DNS server is already different than the one we originally tried there's no point in switching.

    Is that the request?

  10. vicinus commented on Dec 29, 2020

    @vicinus
    Author

    Sorry, for my late reply, I did somehow miss your reply. Your proposed solution will fix our problem and Iooks like the best solution. Thanks for working on this issue.

  11. added a commit that references this issue on Feb 15, 2021
    af959a8
  12. added a commit that references this issue on Feb 15, 2021
    5e8bc85
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions