Categories: cPanelSecurity

Caching Name Server for CentOS 6.x

A caching only DNS server caches DNS query results for the domain name being queried. These chache are stored for pre specified time known as the TTL. A caching only name server will find the answer to name queries and remember the answer the next time you need it. This will shorten the waiting time the next time significantly, especially if you’re on a slow connection.

Step 1: Install the BIND Packages using Yum

Install bind packages using below command. In CentOS the caching-nameserver package has been included with bind package.

# yum install bind bind-chroot
Step 2: Copy default bind configuration File

Copy bind configuration file from bind sample files using below command. Change the path of files as per version you have installed.

cd /var/named/chroot/etc
cp /usr/share/doc/bind-9.9.2/sample/etc/named.conf  .
cp /usr/share/doc/bind-9.9.2/sample/etc/named.rfc1912.zones  .
Step 3: Make changes in Configuration File

Edit bind configuration file in your favorite editor and make necessory changes as per below settings or use below configuration.

// /var/named/chroot/etc/named.conf
options {
        listen-on port 53 { 127.0.0.1; any; };
        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";
        allow-query     { localhost; any; };
        allow-query-cache    { localhost; any; };
        recursion yes;

        dnssec-enable yes;
        dnssec-validation yes;
        dnssec-lookaside auto;

        /* Path to ISC DLV key */        bindkeys-file "/etc/named.iscdlv.key";

        managed-keys-directory "/var/named/dynamic";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

include "/etc/named.rfc1912.zones";

Update permissions on configuration files.

# chown root:named named.conf named.rfc1912.zones
Step 4: Check Configuration File

We recommend to check dns configuration file before restarting service.

# named-checkconf named.conf
Step 5: Restart Bind Service

Start Bind (named) service using below command.

# service named restart

Enable auto start bind service on system boot.

# chkconfig named on
Step 6: Finally test Caching Only DNS Setup

Send query to your dns server directly using below command.
Syntax: nslookup < domainname > < caching dns server name/ip >

# nslookup Hostripples.com 192.168.1.1

Sample Output:

Server:         192.168.1.1
Address:        192.168.1.1#53

Non-authoritative answer:
Name:   hostripples.com
Address: 198.27.89.220
Name:   hostripples.com
Address: 198.27.89.220

That’s it – your caching server is ready to go.


Vishwajit Kale
Vishwajit Kale blazed onto the digital marketing scene back in 2015 and is the digital marketing strategist of Hostripples, a company that aims to provide affordable web hosting solutions. Vishwajit is experienced in digital and content marketing along with SEO. He's fond of writing technology blogs, traveling and reading.

Recent Posts

The Ultimate Guide to WordPress Maintenance: Tips and Tricks

When you’re running a business that relies on website traffic and sales to succeed. Then you need to keep it…

6 days ago

Migrate In 2024: Our Comprehensive Website Migration Manual to the Next Level

Migration! Yes, this word is very big in the web hosting industry and it has its importance. Especially for businesses…

1 week ago

Unveiling the Importance of Server Maintenance Plans: A Comprehensive Guide

The server is the backbone of the web hosting industry and it acts like a HERO in the web hosting…

2 weeks ago

IP Address is Blocked? A handpicked list of Solutions to Fix it?

Imagine you are on holiday having a cup of tea and browsing your website or blog.Then, what next?You will get…

3 weeks ago

Explained: Difference between Nameservers Vs. DNS

The web hosting industry is growing every minute, day, and year. It has many terminologies that are important to understand…

1 month ago