Activities

December 2009
M T W T F S S
« Nov   Jan »
 123456
78910111213
14151617181920
21222324252627
28293031  

Setting up Caching nameserver on Linux

This are the simple steps configure a caching DNS server which will increase your dnslookup speed on LAN.

1. I uses Centos5 operating system.
2, Install BIND packages

<strong>#yum install bind bind-chroot bind-libs bind-utils caching-nameserver</strong>

#

yum install caching-nameserver

( It’s a sample named.conf file placed on /var/named/chroot/etc/ after the installation)
3. Edit the default file to accept the DNS query from our network. I supposed to be configure caching server on the ip 192.168.0.25 and our network is 192.168.0.0/24

 [root@rc-025 ~]# vi /var/named/chroot/etc/named.caching-nameserver.conf
options {
        listen-on port 53 { 127.0.0.1;192.168.0.25; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";

        // Those options should be used carefully because they disable port
        // randomization
        // query-source    port 53;
        // query-source-v6 port 53;

        allow-query     { "any";};
forwarders { 125.22.47.125;125.224.7.125; };
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

view localhost_resolver {
        match-clients      { localhost;192.168.0.0/24; };
        match-destinations { localhost;192.168.0.0/24; };
        recursion yes;
        include "/etc/named.rfc1912.zones";
};

Modified lines are

1. listen-on port 53 { 127.0.0.1;192.168.0.25; };
2. allow-query { “any”;};
3. forwarders { 125.22.47.125;125.224.7.125; }; //my ISP’s DNS servers
4. match-clients { localhost;192.168.0.0/24; };
5. match-destinations { localhost;192.168.0.0/24; };

How do I testing whether caching is working
Open the terminal of the server where cache server is configured and given a DNS lookup querry to non cached domain name, See the examples shown below,

[root@rc-025 ~]# nslookup alex.com
Server: 192.168.0.8
Address: 192.168.0.8#53

Non-authoritative answer:
Name: alex.com
Address: 216.194.89.122

[root@rc-025 ~]# nslookup alex.com
Server: 127.0.0.1
Address: 127.0.0.1#53

Non-authoritative answer:
Name: alex.com
Address: 216.194.89.122

In my server I have configured the the /etc/resolve.conf file
nameserver 127.0.0.1
nameserver 192.168.0.8

First time a DNS query is looking dns entry on the local server. It did not resolved and look the query to next sever and was resolved at secondary dns (192.168.0.8). I again generated the dns query and which is solved by the local server since the cache is configured on it.

-Enjoy

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>