[Dnsmasq-discuss] Is there any way to cache beyond TTL?

gypsy at iswest.com gypsy at iswest.com
Sun Jun 28 20:21:04 BST 2009


Quoting Perl Whore <whoreperl at gmail.com>:

> Hello,
> 
> I tried setting the local-ttl option, but it does not cache beyond the
> TTL. I was wondering if there is a setting available or patch
> available to get around that?
> 
> Currently running Dnsmasq version 2.46 (Fedora 11).

I'm not sure I understand your question.  The whole idea of a DNS resolver is to
cache until TTL expires.  Dnsmasq allows you to configure TTL for your own
records, but not for anyone else's.

You have to patch rfc1035.c yourself to alter TTL for non-local records.  Simon
does not believe in altering someone else's TTL.  Usually, the person who
determined the TTL value set it as long as possible for his circumstances, and
messing with that is NOT A GOOD IDEA.

I have some code to accomplish that, but not for 2.46.  The following multiplies
the TTL by 2.  NOTE that this is a snip, not the entire "patch"!:
--- src/rfc1035.c.orig  2007-02-05 17:34:32.000000000 -0800
+++ src/rfc1035.c       2007-02-06 15:39:27.000000000 -0800
@@ -530,6 +530,7 @@
       GETSHORT(qclass, p);
       GETLONG(ttl, p);
       GETSHORT(rdlen, p);
+      ttl = ttl * 2;

       if ((qclass == C_IN) && (qtype == T_SOA))
        {
@@ -547,6 +548,7 @@

          GETLONG(ttl, p); /* minTTL */
          if (ttl < minttl)
+            ttl = ttl * 2;
            minttl = ttl;
        }
       else
--
gypsy



More information about the Dnsmasq-discuss mailing list