2

I am using bind-9.3.6-4 in my CentOS 5. How can I allow bind to cache lookup queries so that if there are similar queries it should check from my cache instead doing a lookup from the DNS servers mentioned in the "forwarders"?

Supratik
  • 2,104
  • 10
  • 49
  • 66
  • 2
    What makes you think it's not cacheing now? – MadHatter Oct 13 '11 at 14:53
  • @MadHatter I am firing some curl request to a particular domain and often I am getting "name lookup timed out" error. When I am executing nslookup for that domain at that instant it is taking more time to resolve. If it is fetching it from cache, how do I verify? – Supratik Oct 14 '11 at 13:46

1 Answers1

2

An out of the box bind install via yum should be a caching.

There are three kinds of name servers - caching, resolving, and authoritative. Bind acts as all three out of the box, but you'll need to tell it what you want it to be authoritative for. You can use dig to query the server - the answer will have a decrementing counter in it that shows how long it will be before the cache expires. This is the TTL of the record and it should show the time left in the cache.

Here is sample output for a simple dig for google .com against a local name server.

$ dig google.com

; <<>> DiG 9.7.3 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53888
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0

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

;; ANSWER SECTION:
google.com.             291     IN      A       173.194.33.20
google.com.             291     IN      A       173.194.33.16
google.com.             291     IN      A       173.194.33.18
google.com.             291     IN      A       173.194.33.17
google.com.             291     IN      A       173.194.33.19

;; Query time: 32 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Tue Nov 29 14:54:02 2011
;; MSG SIZE  rcvd: 108

The 291 shows that this server has 291 seconds left to go before it resolves again, showing that the SERVER in the bottom lines will give out the same answer until google.com has expired from the cache.

I think a look at the dig documentation would do you well - it will allow you to ask an appropriate followup question.

Ben
  • 337
  • 1
  • 2
  • 15