Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Uncategorized»How to Setup Master Slave DNS Server on CentOS 6 and RHEL

    How to Setup Master Slave DNS Server on CentOS 6 and RHEL

    RahulBy RahulMay 21, 20134 Mins Read

    The DNS ( Domain Name System ) is a distributed system, used for transalate domain names to IP and vice a versa. This article will help you to How to Setup Master Slave DNS Server on CentOS 6 and RHEL Systems.

    Network Scenario for this Setup
    Master DNS Server IP: 192.168.1.90 ( ns1.tecadmin.net )
    Slave  DNS Server IP: 192.168.1.91 ( ns2.tecadmin.net )
    Domain Name : demotecadmin.net   ( For Testing Purpose )
    Domain IP   : 192.168.1.100  ( For Testing Purpose )
    
    Step 1: Install Required RPMS ( at Master and Slave Both )

    Install bind packages at both Master and Slave dns servers using following commands.

    # yum install bind bind-chroot
    
    Step 2: Setup Master (NS1) DNS Server

    There are two types of configuration files in DNS.

    • One is main dns configuration files named “named.conf”
    • Another type of configuration file are called zone file. Which is individually created for all domains. named.conf keeps an entry for all zone files.
    2.1 Configure named.conf using below configuration
    # vim /var/named/chroot/etc/named.conf
    

    Content of named.conf:

    // /var/named/chroot/etc/named.conf
    options {
            listen-on port 53 { 127.0.0.1; 192.168.1.0/24; };
            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; 192.168.1.0/24; };
            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;
            };
    };
    
    zone "." IN {
            type hint;
            file "named.ca";
    };
    
    zone "demotecadmin.net" IN {
            type master;
            file "/var/named/demotecadmin.net.db";
    	allow-update { none; };
    };
    
    include "/etc/named.rfc1912.zones";
    

    [Change red highlighted values as per you network and domain name ]

    2.2 Create a zone file for you domain “demotecadmin.net”
    # vim /var/named/chroot/var/named/demotecadmin.net.db
    

    Content of zone file:

    ; Zone file for demotecadmin.net
    $TTL 14400
    @      86400    IN      SOA     ns1.tecadmin.net. webmaster.tecadmin.net. (
                    3215040200      ; serial, todays date+todays
                    86400           ; refresh, seconds
                    7200            ; retry, seconds
                    3600000         ; expire, seconds
                    86400 )         ; minimum, seconds
    
    demotecadmin.net. 86400 IN NS ns1.tecadmin.net.
    demotecadmin.net. 86400 IN NS ns2.tecadmin.net.
    demotecadmin.net. IN A 192.168.1.100
    demotecadmin.net. IN MX 0 demotecadmin.net.
    mail IN CNAME demotecadmin.net.
    www IN CNAME demotecadmin.net.
    
    2.3 Add more domains in dns server

    To add more domains in dns, create zone files individually for all domain as above. After that add any entry for all zones in named.conf like below. Change demotecadmin.net with your domain name.

    zone "demotecadmin.net" IN {
            type master;
            file "/var/named/demotecadmin.net.db";
    	allow-update { none; };
    };
    
    Step 2.4: Start named service

    Start named (bind) service using following command and setup auto start on system boot.

    # /etc/init.d/named restart
    # chkconfig named on
    
    Step 3: Setup Slave (NS2) DNS Server

    At slave dns server you need to update named.conf file only. All zone files will automatically synced from master dns server. Any changes done on Master will reflect on slave after a specified time interval.

    3.1 Configure named.conf using below configuration
    # vim /var/named/chroot/etc/named.conf
    

    Content of named.conf

    // /var/named/chroot/etc/named.conf
    options {
            listen-on port 53 { 127.0.0.1; 192.168.1.0/24; };
            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; 192.168.1.0/24; };
            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;
            };
    };
    
    zone "." IN {
            type hint;
            file "named.ca";
    };
    
    zone "demotecadmin.net" IN {
    	type slave;
            file "slaves/demotecadmin.net.db";
    	masters { 192.168.1.90; };
    };
    
    include "/etc/named.rfc1912.zones";
    
    Step 3.2: Start named Service

    Start named (bind) service using below command.

    # /etc/init.d/named restart
    # chkconfig named on
    

    After restarting named service, Check zone files on slave dns server at /var/named/chroot/var/named/slaves/.

    Step 4: Finally Test Your DNS Setup

    Query to your Master and Slave DNS Server directly using following commands, You will get the same resonse from both servers.
    Syntax: nslookup <domainname.com> <dns server name/ip>

    Query to Master DNS Server:

    # nslookup demotecadmin.net 192.168.1.90
    
    Server:         192.168.1.90
    Address:        192.168.1.90#53
    
    Name:   demotecadmin.net
    Address: 192.168.1.100
    

    Query to Slave DNS Server:

    # nslookup demotecadmin.net 192.168.1.91
    
    Server:         192.168.1.91
    Address:        192.168.1.91#53
    
    Name:   demotecadmin.net
    Address: 192.168.1.100
    

    Above outputs is showing that dns server has successfully resolved domain demotecadmin.net from master and slave dns servers.

    Read more about dns servers http://en.wikipedia.org/wiki/Name_server

    bind master dns master slave dns. dns named setup bind slave dns
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Change Document Root of Primary Domain in WHM/cPanel
    Next Article How to Upgrade Git version >= 1.7.10 on CentOS 6

    Related Posts

    Most Effective Industry Specific Plug-ins for WordPress

    Updated:August 15, 20163 Mins Read

    How to Setup Forward Only DNS Server on Ubuntu & Debian

    Updated:February 15, 20202 Mins Read

    How to Setup Your Own DNS Server on Ubuntu & Debian

    Updated:April 25, 20224 Mins Read

    How to Install Komodo Edit on Ubuntu 14.10, 14.04 LTS and 12.04 LTS via PPA

    1 Min Read

    How to Setup Caching NameServer on CentOS/RHEL 6/5

    2 Mins Read

    Setup Database Mirroring in SQL Server 2012 with Certificates

    3 Mins Read

    1 Comment

    1. alimp5 on October 13, 2015 6:23 am

      Tnxxx

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Import GPG Keys on Ubuntu & Debian (without apt-key)
    • How To Install Google Chrome On macOS
    • How to Install Minecraft on Ubuntu 22.04 & 20.04
    • Running a Cron job every Sunday (Weekly)
    • Running Multiple Commands At Once in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.