Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running a caching DNS server currently to improve latency in a network.

The question is: can I override the TTL I get from a server using BIND9 or other software on Linux?

short "dig www.google.com" here:

; <<>> DiG 9.6.1-P2 <<>> www.google.com

;; ANSWER SECTION: www.google.com. 604441 IN CNAME www.l.google.com. www.l.google.com. 300 IN A 74.125.45.147

Can I change that '300' into 15 minutes?

Thanks you so much for your time!!.

share|improve this question
1  
As mentioned several times, please don't do this. Just take a quick look around on serverfault to find out how many questions there are from sysadmins who have to deal with DNS servers that don't obey the TTL. Try: serverfault.com/questions/54758/… or serverfault.com/questions/103281/… or serverfault.com/questions/96453/… –  Mark Henderson Feb 17 '10 at 22:03
    
Do not worry it was a proof of concept, that CAN be done. Also this will not propagate more than 2 people in this network. And this was part as an Academic effort to show a internet connection with the lowest latency possible. I understand your concerns. This was the first time I use this web page, and I'm amazed by the good replies. –  OmniWired Feb 18 '10 at 0:10

3 Answers 3

CAN this be done? Sure - there are broken DNS servers (e.g. the ones AOL runs) that do this, and every admin I know hates it.

SHOULD this be done? Almost certainly no.

Generally speaking the TTL was set to a particular value for a reason (in google's case, probably fault tolerance: You'll only be unable to reach google for 5 minutes if that server blows up), and you shouldn't muck about with it.

You're already getting a performance boost by keeping the google.com record in your cache for the 5 minutes it's intended to live for since your individual workstations won't be running out to the internet for resolution -- don't over-optimize and break the expected behavior :)

share|improve this answer
    
should I change the question and say: how can I run a evil, not standard compliant server, so evil it cache for 15 minutes? So I can learn "what shouldn't be done". Thanks you everyone for the quick responses. – –  OmniWired Feb 17 '10 at 20:33
    
You could TAKE OVER THE WORLD this way. Muaaahahahaha. Yes. Evil. –  kubanczyk Feb 17 '10 at 20:52
    
yes, and learning in the process, amazing! I'm sure it can be done, but I can't seem to find an answer... Maybe with some crazy BIND9 configuration zone... –  OmniWired Feb 17 '10 at 21:00
1  
Well, my general intent was to convince you not to do it. If you insist the only way I know of would be to actually to patch BIND to add a min-cache-ttl configuration directive (analogous in function to the existing max-cache-ttl). AFAIK no caching DNS server in the wild allows you to do this, though I haven't looked at Microsoft's... –  voretaq7 Feb 17 '10 at 21:09
    
I thought that as well. I'm downloading dnsmasq source as we speak. I believe will be easier to patch dnsmasq because the source code to analyze is shorter. –  OmniWired Feb 17 '10 at 21:14
up vote 3 down vote accepted

the DIRTIEST most ugliest thing that can be done is...

1-Downloading the source 2-find the file called cache.c 3-find the function is_expired

4- Change it in this way

static int is_expired(time_t now, struct crec *crecp)
{
  if (crecp->flags & F_IMMORTAL)
    return 0;

  if (difftime(now, crecp->ttd) < 0)
    return 0;

  return 0; // IT WAS IN ONE
}

When the function ask did expire? we always saw no

In this way it will never expire and you will conquer the world.

OUTPUT:

; <<>> DiG 9.6.1-P2 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28477
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.google.com.            IN  A

;; ANSWER SECTION:
www.google.com.     603937  IN  CNAME   www.l.google.com.
www.l.google.com.   4294966733 IN   A   209.85.195.99
www.l.google.com.   4294966733 IN   A   209.85.195.104
www.l.google.com.   4294966733 IN   A   209.85.195.147

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Feb 17 18:34:47 2010
;; MSG SIZE  rcvd: 110
share|improve this answer
3  
+1 for continuous urge to take over the world (and learn in the process). –  kubanczyk Feb 20 '10 at 12:22

See similar question here http://serverfault.com/questions/86968/dnsmasq-how-to-increase-ttl and another one here http://serverfault.com/questions/86970/is-there-an-alternative-to-dnsmasq

share|improve this answer
    
in that question it doesn't fix my problem. I need to cache for longer periods of time (more than 300 seconds) one particular web site. –  OmniWired Feb 17 '10 at 20:09
    
The dnsmasq article point to this: "Normally responses which come form /etc/hosts and the DHCP lease file have Time-To-Live set as zero, which conventionally means do not cache further. If you are happy to trade lower load on the server for potentially stale date, you can set a time-to-live (in seconds) here." And is not what I'n looking to accomplish. I want to use an address resolved by the dns for a longer period than the one I been given –  OmniWired Feb 17 '10 at 20:14
    
@omniwired - The reason you can reduce the TTL is because TTL = "You may cache this record for at most S seconds". Good, Correct DNS servers shouldn't ever let you cache records longer than their TTL... –  voretaq7 Feb 17 '10 at 20:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.