Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Improving DNS Cache

    Scheduled Pinned Locked Moved DHCP and DNS
    6 Posts 2 Posters 925 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      Ashkaan
      last edited by

      Hi there,

      I'm wondering how I can configure Unbound (or any DNS server) to have a large cache and then auto-update each entry as the TTL expires.

      My understanding is that after the TTL expires, the item is removed instead of updated.

      I just want my internet browsing to feel like it's lightning fast.

      Thanks!

      johnpozJ 1 Reply Last reply Reply Quote 0
      • johnpozJ Offline
        johnpoz LAYER 8 Global Moderator @Ashkaan
        last edited by johnpoz

        @ashkaan Unbound has a feature called serve expired - which is what your looking for. Even after the ttl has expired it will serve the last known IP, and then lookup the entry.

        You can also turn on prefetch... This means as the ttl gets close to expiring and someone asks for that it will be looked up again so that the ttl should be full again.

        These settings are both in the advanced section of unbound.

        Your common accessed stuff should always be in cache with prefetch, and even uncommon stuff that has expired should be served from cache - but the client will be handed a ttl of 0 for stuff that has expired - so if for whatever reason that doesn't work - next time he asks for that, ie a reload of the page you would get whatever is current..

        I run with both of these settings and have had zero issues with anything I access.

        An intelligent man is sometimes forced to be drunk to spend time with his fools
        If you get confused: Listen to the Music Play
        Please don't Chat/PM me for help, unless mod related
        SG-4860 24.11 | Lab VMs 2.8, 24.11

        A 1 Reply Last reply Reply Quote 0
        • A Offline
          Ashkaan @johnpoz
          last edited by

          @johnpoz Thank you so much for the response.
          I'm actually not wanting to serve expired addresses. I'm wanting the DNS server to run out and get new addresses just as a TTL will expire so that it's ready to go before the user even makes a request.
          I have a 500GB NVMe drive on my pfsense, so resources don't matter to me.

          johnpozJ 1 Reply Last reply Reply Quote 0
          • johnpozJ Offline
            johnpoz LAYER 8 Global Moderator @Ashkaan
            last edited by johnpoz

            @ashkaan that is prefetch. But there is nothing that does what your asking - the serve zero does what your asking, and so does the the prefetch..

            If you want something to make sure records are cached - then you would have to create a script that queries those on some time schedule..

            Prefetch will only go ask for stuff again if the ttl is close and something actually did a query for that something.. It doesn't on its own go and refresh the ttl, unless it was asked for.

            Been doing dns for as long as there has been dns - and what your asking for makes no sense.. The serve zero and prefetch accomplish what your asking.. But also don't continue to query for something that is no longer needed..

            In your scenario 1 time things that get asked for once - ie some ad fqdn. Would constantly require dns queries, and if they used a short ttl - like 60 seconds, you would constantly be asking for that.. As those unique records started to add up you could end up asking for 1000s of things every second that nobody on your network even wants to go to anymore..

            An intelligent man is sometimes forced to be drunk to spend time with his fools
            If you get confused: Listen to the Music Play
            Please don't Chat/PM me for help, unless mod related
            SG-4860 24.11 | Lab VMs 2.8, 24.11

            A 1 Reply Last reply Reply Quote 0
            • A Offline
              Ashkaan @johnpoz
              last edited by

              @johnpoz You're right. Continuing to query for something that no one wants anymore is exactly what I'm looking for.

              Again, I have nearly infinite resources so I'm not worried about that.

              It sounds like serve 0 and prefetch are as close as I'm going to get. Thank you so much for the info!

              johnpozJ 1 Reply Last reply Reply Quote 0
              • johnpozJ Offline
                johnpoz LAYER 8 Global Moderator @Ashkaan
                last edited by

                @ashkaan said in Improving DNS Cache:

                Continuing to query for something that no one wants anymore is exactly what I'm looking for.

                And you get it in your head to do such nonsense and then the next guy as well and the next guy as well.. And next thing you know you have millions of queries a second for stuff nobody is actually wanting to look up.

                If not 10's of billions.. Prefetch and serve zero will mean your clients get served from cache.. As long as some point in the past that thing was asked for and in the cache.

                An intelligent man is sometimes forced to be drunk to spend time with his fools
                If you get confused: Listen to the Music Play
                Please don't Chat/PM me for help, unless mod related
                SG-4860 24.11 | Lab VMs 2.8, 24.11

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.