Setting up local DNS server on CentOS/Red Hat 6

Install required packages

yum install bind bind-utils bind-chroot

Configuration

vi /etc/named.conf

listen-on port 53 { 127.0.0.1; 192.168.100.26; };
listen-on-v6 port 53 { none; };
allow-query     { localhost; 192.168.100.0/24; };

logging {
        channel default_file {
                file "/var/log/named.log" size 50m;
                severity dynamic;
                print-time yes;
                print-severity yes;
                print-category yes;
        };
        category default{ default_file; };
};

zone "corneschi.local" IN {
       type master;
       file "db.corneschi.local";
};

zone "100.168.192.in-addr.arpa" {
    type master;
    file "db.100.168.192";
};

Disable IPv6

echo 'OPTIONS="-4"' >> /etc/sysconfig/named

Create the zone

vi /var/named/db.corneschi.local

$TTL 86400
@   IN  SOA     ns1.corneschi.local. hostmaster.corneschi.local. (
        2017040501  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
                IN      NS              ns1.corneschi.local.
ns1             IN      A               192.168.100.22
c6vm01prod      IN      CNAME           ns1

Create the reverse zone

vi /var/named/db.100.168.192

$TTL 86400
@   IN  SOA     ns1.corneschi.local. hostmaster.corneschi.local. (
        2017040501  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
                IN      NS              ns1.corneschi.local.
ns1             IN      A               192.168.100.22
22              IN      PTR             c6vm01prod.corneschi.local.

Activate BIND at boot and start the service

chkconfig named on && service named start

Useful commands

  • Check DNS statistics: service named status
  • Check the syntax and integrity of a zone file: named-checkzone corneschi.local /var/named/db.corneschi.local
  • Check the syntax but not the semantics of the configuration file: named-checkconf -t /var/named/chroot
  • Report the version number and build options: named -V
  • Print the domain part of the FQDN: dnsdomainname
  • Check if named is running under chroot: ps -ef | grep named
  • Reload configuration file and zones: rndc reload
  • Toggle query logging (check /var/log/messages), same command for off: rndc querylog

Files

  • /etc/named.conf
  • /etc/sysconfig/named
  • /var/named/chroot/var/log/named.log
  • /var/named/data/named.run

Online Tools

Links