Setup DNS Server for IPv6 and IPv4 queries using Bind9 in CentOS Linux

So here’s how to setup your own IPv6 and IPv4 capable dns server in linux using bind v9. I will make this short only and straight forward so you wont get bored 😉

Let’s get started! First, we need to install Bind v9 through yum software package manager.

yum -y install bind

If you want to use MySQL to store your zone files then you can do so by installing its driver. This is however optional as you can use plain text file to store zone entries.

yum -y install bind-sdb

Now, start that named daemon.

service named start

Now, modify your configuration file in /etc/named.conf to have your domain’s zone file. In this guide, I configured it to answer for’s dns queries. Refer to sample code below.

// named.conf
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
// See /usr/share/doc/bind*/sample/ for example named configuration files.

options {
        listen-on port 53 {;;};
        listen-on-v6 port 53 { ::1; 2001:fe0:1111:1::103;};
        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     { 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/";
                severity dynamic;

zone "." IN {
        type hint;
        file "";

zone "" IN {
        type master;
        file "/etc/named/";

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

Below is a sample zone file of the domain which you can copy and modify it to reflect to your domain, aliases and address

$TTL 1200     IN      SOA (
        2012090804 ; serial
        1200 ; refresh
        1200 ; retry
        2149200 ; expire
        3600 ) ; negative cache ttl

@       IN AAAA 2001:fe0:1111:1::103
@       IN MX 10
@       IN NS
@       IN NS

; A Records
ns1     IN A
ns2     IN A
mail    IN A

; AAAA Records
ns2     IN AAAA 2001:fe0:1111:1:a00:27ff:fe2f:78bb
ns1     IN AAAA 2001:fe0:1111:1::103
www     IN AAAA 2001:fe0:1111:1:a00:27ff:fe2f:78bb
mail    IN AAAA 2001:fe0:1111:1:a00:27ff:fe2f:78bb

Before you perform any dns lookups for your domain, you need to set your name servers first in your domain registrar to the name server you’ve just setup, then to check if your configured dns server answers queries for your domain, you use the nslookup tool.

Below is the output of the nslookup performed for the hostname

shell# nslookup

Address:  2001:fe0:1111:1:a00:27ff:fe2f:78bb

Leave a Reply

Your email address will not be published. Required fields are marked *