Skip to content

systemd-resolved negative caching for extended period of time #5552

Closed

Description

@xnox

Submission type

  • Bug report
  • Request for enhancement (RFE)

systemd version the issue has been seen with

231

Used distribution

Ubuntu 231-9ubuntu3

Over on launchpad (https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1668771), the following bug report was received. I am guessing it related to relatively recent SERVFAIL fixes #3594 . Is SERVFAIL result cached? And does the cache of such result ever expire?

Original bug report

If a DNS lookup returns SERVFAIL, systemd-resolved seems to cache the result for very long (infinity?). I have to restart systemd-resolved to have the negative caching purged.

After SERVFAIL DNS server issue has been resolved, chromium/firefox still returns DNS error despite host can correctly resolve the name.

Activity

  1. changed the title [-]systemd-resolved negative caching for extended period of time Edit[/-] [+]systemd-resolved negative caching for extended period of time[/+] on Mar 7, 2017
  2. poettering commented on Mar 29, 2017

    @poettering
    Member

    We cache SERVFAIL for 30s now. Are you saying it is cached longer for you?

    See 201d995

  3. added
    needs-reporter-feedback ❓
    on Mar 29, 2017
  4. zerkms commented on Jun 26, 2018

    @zerkms
    Contributor

    It's happening to me at this very moment: systemd 237-3ubuntu10 installed on ubuntu bionic.

    The hostname was first resolved before it was added to the local DNS, then even after it was added systemd-resolve fails to resolve it even after few minutes.

    The systemd-resolve config:

    [Resolve]
    DNS=10.50.5.9 10.50.5.10 
    

    and my current observations:

    $ systemd-resolve hostname.tld.redacted
    hostname.tld.redacted: resolve call failed: 'hostname.tld.redacted' not found
    
    
    $ dig hostname.tld.redacted
    
    ; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> hostname.tld.redacted
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 49560
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 65494
    ;; QUESTION SECTION:
    ;hostname.tld.redacted.	IN	A
    
    ;; Query time: 0 msec
    ;; SERVER: 127.0.0.53#53(127.0.0.53)
    ;; WHEN: Tue Jun 26 02:16:12 UTC 2018
    ;; MSG SIZE  rcvd: 53
    
    
    
    $ dig hostname.tld.redacted @10.50.5.10
    
    ; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> hostname.tld.redacted @10.50.5.10
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36607
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
    
    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 4096
    ; COOKIE: d14148fba8554e74a9cafb725b31a1fcaf29f9440d12a116 (good)
    ;; QUESTION SECTION:
    ;hostname.tld.redacted.	IN	A
    
    ;; ANSWER SECTION:
    hostname.tld.redacted. 3600	IN	A	10.50.5.9
    
    ;; Query time: 0 msec
    ;; SERVER: 10.50.5.10#53(10.50.5.10)
    ;; WHEN: Tue Jun 26 02:16:28 UTC 2018
    ;; MSG SIZE  rcvd: 150
    
  5. zerkms commented on Jun 26, 2018

    @zerkms
    Contributor

    While researching it I emitted getent hosts hostname.tld.redacted and it presumably cleared the cache.

    So the negative cache entry was there for at least an hour.

  6. voggur commented on Feb 6, 2019

    @voggur

    Is it possible to disable negative caching in resolved.conf ?

  7. xnox commented on Feb 9, 2019

    @xnox
    ContributorAuthor

    One can flush caches, using

    $ resolvectl flush-caches 
    $ systemd-resolve --flush-caches
    

    And one can disable all caching in /etc/systemd/resolved.conf by setting Cache=no, if the key is listed there.

    Not sure if we need to change Cache to a tri-state to allow "no, no-negative, yes" values.

  8. Spenser309 commented on Apr 11, 2019

    @Spenser309

    Please default to no-negative. Caching is useful but in general SOA records are set to 15 min by default which can be long for dynamically changing cloud apps.

  9. rhamon commented on Jun 6, 2019

    @rhamon

    Disabling negative caching is crucial when using consul or other service discovery that work on dns, would be sad having to disable caching completely.

  10. niedbalski commented on Jul 16, 2019

    @niedbalski
    Contributor

    I've submitted a proposal PR for addressing the tri-state cache option. Please check #13047

  11. 1 remaining item

  12. removed
    needs-reporter-feedback ❓
    on Nov 27, 2020
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