Improving DNS Cache
-
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!
-
@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.
-
@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. -
@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..
-
@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!
-
@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.