JumpStart I: Setting Up a DNS Cache


As explained earlier, a DNS cache is a bridge between a resolver and authoritative DNS servers: It is not authoritative; it simply stores the results of its queries in memory. Most ISPs provide a DNS cache for the use of their customers. Setting up a local cache can reduce the traffic between the LAN and the outside world and can improve response times. While it is possible to set up a DNS cache on each system on a LAN, setting up a single DNS cache on a LAN prevents multiple systems on the LAN from having to query a remote server for the same information.

After installing BIND, including the bind-config package (see the caution box on page 732), you have most of a caching-only nameserver ready to run. Refer to "A DNS Cache" (page 742) for an explanation of which files this nameserver uses and how it works. Before you start the DNS cache, put the following line in /etc/resolv.conf (page 455), before any other nameserver lines:

nameserver 127.0.0.1


This line tells the resolver to use the local system (localhost or 127.0.0.1) as the primary nameserver. To experiment with using the local system as the only nameserver, comment out other nameserver lines in resolv.conf by preceding each with a pound sign (#).

Finally, start the named daemon using service as explained in the "Prerequisites" section (page 731). Refer to "Troubleshooting" on page 751 for ways to check that the DNS cache is working. Once named is running, you can see the effect of the cache by using dig to look up the IP address of www.redhat.com, a remote system:

$ dig www.redhat.com ; <<>> DiG 9.3.2 <<>> www.redhat.com ;; global options:  printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38263 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.redhat.com.                        IN      A ;; ANSWER SECTION: www.redhat.com.         60      IN      A       209.132.177.50 ;; AUTHORITY SECTION: redhat.com.             600     IN      NS       ns1.redhat.com. redhat.com.             600     IN      NS       ns2.redhat.com. redhat.com.             600     IN      NS       ns3.redhat.com. ;; Query time: 496 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Wed Mar 29 18:55:37 2006 ;; MSG SIZE  rcvd: 102


The fourth line from the bottom shows that the query took 496 milliseconds (about one-half of a second). When you run the same query again, it runs more quickly because the DNS cache has saved the information in memory:

$ dig www.redhat.com ... ;; Query time: 2 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Wed Mar 29 18:55:43 2006 ;; MSG SIZE  rcvd: 102





A Practical Guide to Red Hat Linux
A Practical Guide to Red HatВ® LinuxВ®: Fedoraв„ў Core and Red Hat Enterprise Linux (3rd Edition)
ISBN: 0132280272
EAN: 2147483647
Year: 2006
Pages: 383

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net