DNS Caching

I've been writing some DNS articles over the past couple of months, and I wanted to keep the momentum going with a discussion on DNS Caching.  As a reminder, my first five articles are:

  1. Let's Talk DNS on DevCentral
  2. DNS The F5 Way: A Paradigm Shift
  3. DNS Express and Zone Transfers
  4. The BIG-IP GTM: Configuring DNSSEC
  5. DNS on the BIG-IP: IPv6 to IPv4 Translation


We all know that caching improves response time and allows for a better user experience, and the good news is that the BIG-IP is the best in the business when it comes to caching DNS requests.  When a user requests access to a website, it's obviously faster if the DNS response comes directly from the cache on a nearby machine rather than waiting for a recursive lookup process that spans multiple servers.  The BIG-IP is specifically designed to quickly and efficiently respond to DNS requests directly from cache.  This cuts down on administrative overhead and provides a better and faster experience for your users.

There are three different types of DNS caches on the BIG-IP:  Transparent, Resolver, and Validating Resolver.  In order to create a new cache, navigate to DNS >> Caches >> Cache List and create a new cache (I'm using v11.5).  Let's check out the details of each one!


Transparent Resolver

When the BIG-IP is configured with a transparent cache, it uses external DNS resolvers to resolve DNS queries and then cache the responses from the resolvers.  Then, the next time the BIG-IP receives a query for a response that exists in cache, it immediately returns the response to the user.  Transparent cache responses contain messages and resource records.  The diagram below shows a transparent cache scenario where the BIG-IP does not yet have the response to a DNS query in its cache.  In this example, the user sends a DNS query, but because the BIG-IP does not have a response cached, it transparently forwards the query to the appropriate external DNS resolver.  When the BIG-IP receives the response from the resolver, it caches the response for future queries. 



A big benefit of transparent caching is that it consolidates content that would otherwise be cached across many different external resolvers.  This consolidated cache approach produces a much higher cache hit percentage for your users.  The following screenshot shows the configuration options for setting up a transparent cache. 



Notice that when you select the "Transparent" Resolver Type, you simply configure a few DNS Cache settings and you're done!  The Message Cache Size (listed in bytes) is the maximum size of the message cache, and the Resource Record Cache Size (also listed in bytes) is the maximum size of the resource record cache.  Pretty straightforward stuff. 

The "Answer Default Zones" setting is not enabled by default; meaning, it will pass along DNS queries for the default zones.  When enabled, the BIG-IP will answer DNS queries for the following default zones:  localhost, reverse and ::1, and AS112.  The "Add DNSSEC OK Bit On Miss" setting is enabled by default., and simply means that the BIG-IP will add the DNSSEC OK bit when it forwards DNS queries.  Adding this bit indicates to the server that the resolver is able to accept DNSSEC security resource records. 




Whereas the Transparent cache will forward the DNS query to an external resolver, the "Resolver" cache will actually resolve the DNS queries and cache the responses. The Resolver cache contains messages, resource records, and the nameservers that the BIG-IP queries to resolve DNS queries.  The screenshot below shows the configuration options for setting up a Resolver cache.



When you select the Resolver cache, you will need to select a Route Domain Name from the dropdown list.  This specifies the route domain that the resolver uses for outbound traffic.  The Message Cache Size and Resource Record Cache Size are the same settings as in Transparent cache.  The Name Server Cache Count (listed in entries) is the maximum number of DNS nameservers on which the BIG-IP will cache connection and capability data.  The Answer Default Zones is the same setting as described above for the Transparent cache.

As expected, the Resolver cache has several DNS Resolver settings.  The "Use IPv4, IPv6, UDP, and TCP" checkboxes are fairly straightforward.  They are all enabled by default, and they simply specify whether the BIG-IP will answer and issue queries in those specific formats.  The "Max Concurrent UDP and TCP Flows" specifies the maximum number of concurrent sessions the BIG-IP supports.  The "Max Concurrent Queries" is similar in that it specifies the maximum number of concurrent queries used by the resolver.  The "Unsolicited Reply Threshold"  specifies the number of replies to DNS queries the BIG-IP will support before generating an SNMP trap and log message as an alert to a potential attack.  DNS cache poisoning and other Denial of Service attacks will sometimes use unsolicited replies as part of their attack vectors.  The "Allowed Query Time" is listed in milliseconds and specifies the time the BIG-IP will allow a query to remain in the queue before replacing it with a new query when the number of concurrent distinct queries exceeds the limit listed in the "Max Concurrent Queries" setting (discussed above).  The "Randomize Query Character Case" is enabled by default and will force the BIG-IP to randomize the character case (upper/lower) in domain name queries issued to the root DNS servers.  Finally, the "Root Hints" setting specifies the host information needed to resolve names outside the authoritative DNS domains.  Simply input IP addresses of the root DNS servers and hit the "add" button.



Validating Resolver

The Validating Resolver cache takes things to the next level by recursively querying public DNS servers and validating the identity of the responding server before caching the response.  The Validating Resolver uses DNSSEC to validate the responses (which mitigates DNS attacks like cache poisoning).  For more on DNSSEC, you can check out my previous article.  The Validating Resolver cache contains messages, resource records, the nameservers that the BIG-IP queries to resolve DNS queries, and DNSSEC keys.  When an authoritative server signs a DNS response, the Validating Resolver will verify the data prior to storing it in cache.  The Validating Resolver cache also includes a built-in filter and detection mechanism that rejects unsolicited DNS responses.  The screenshot below shows the configuration options for setting up a Validating Resolver cache.


I won't go into detail on all the settings for this page because most of them are identical to the Validating Resolver cache.  However, as you would expect, there are a few extra options in the Validating Resolver cache.  The first is found in the DNS Cache settings where you will find the "DNSSEC Key Cache Size".  This setting specifies the maximum size (in bytes) of the DNSKEY cache.  The DNS Resolver settings are identical to the Resolver cache.  The only other difference is found in the DNSSEC Validator settings.  The "Prefetch Key" is enabled by default and it specifies that the BIG-IP will fetch the DNSKEY early in the validation process.  You can disable this setting if you want to reduce the amount of resolver traffic, but also understand that, if disabled, a client might have to wait for the validating resolver to perform a key lookup (which will take some time).  The "Ignore Checking Disabled Bit" is disabled by default.  If you enable this setting, the BIG-IP will ignore the Checking Disabled setting on client queries and will perform response validation and only return secure answers. 


Keep in mind that caching is a great tool to use, but it's also good to know how much space you are willing to allocate for caching.  If you allocate too much, you might serve up outdated responses, but if you allocate too little, you will force your users to wait while DNS recursively asks a bunch of servers for information you could have been holding all along.  In the end, it's a reminder that you should know how often your application data changes, and you should configure these caching values accordingly.  Well, that does it for this edition of DNS caching...stay tuned for more DNS goodness in future articles!


Published Jun 12, 2014
Version 1.0

Was this article helpful?


  • Hi jon, on message cache vs rr cache does the composition recommended to be 1/10? For message cache, which field actually does this refers ? does the important is the value of RR that is being compared for the next same query?