Skip to content

systemd-resolved keeps static order of DNS records #16297

Closed

Description

@olifre

Is your feature request related to a problem? Please describe.
When resolving a host which has multiple A records, systemd-resolved always returns the A records in the same order:

# systemd-resolve -4 cloudflare.com
cloudflare.com: 104.17.176.85
                104.17.175.85
# systemd-resolve -4 cloudflare.com
cloudflare.com: 104.17.176.85
                104.17.175.85

While upstream servers may randomize the order upon each query, systemd-resolved keeps the order static within the cache lifetime.

This prevents simple load balancing and, if the first server in the list has an issue, that issue is seen permanently locally.
One example would be if the first server in the list causes SSH connection attempts to hang, which prevents SSH from retrying other servers in the list.

Describe the solution you'd like
Randomization of records to provide load balancing, as other caching resolvers do (e.g. dnsmasq).

Activity

  1. olifre commented on Jul 9, 2020

    @olifre
    Author

    Thanks, that's an interesting read indeed. So that clarifies this is not a "bug" per-se in system-resolved, still, it behaves differently from other resolvers, which either emulate the shuffling of upstream servers or keep the order.

    The problem is that even though I believe the article is correct, shuffling by DNS order may still be useful: When you don't need fault tolerance and traffic locality, and an actual load balancer is not an option (e.g. for SSH you pay the price of bandwidth, which you can't always do), randomly having the client choose from a list is still a good option.
    SSH clients themselves, though, can't do that. Luckily, all DNS cachers I know do either keep the upstream DNS server order or even shuffle the records.

    Is there a specific reason why systemd-resolved chose a different approach? While certainly not wrong, it is very different from how other software behaves.

  2. added
    RFE 🎁
    on Aug 6, 2020
  3. whoo commented on Sep 28, 2020

    @whoo

    Hi,
    I've got the same issue.
    (I'm using the poooooor loadbalancing over DNS to avoid other solution - nginx/haproxy).
    Is a patch is available insted of using dnsmasq.

    Regards.

  4. added 2 commits that reference this issue on Feb 12, 2021
    69f59cf
    3f0a7b3
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

    RFE 🎁resolve

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions