2014/12/28

CentOS 6.5 架設 DNS Server

輸入下方指令安裝DNS
yum install -y bind*

安裝好後,輸入指令編輯配置檔案
vim /etc/named.conf


options {
        listen-on port 53 { 127.0.0.1; 該台IP; };
        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     { any;192.168.100.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 "cy.local" IN {
        type master;
        file "cy.local";
        allow-update {none;};
};

/*反解*/
zone "10.168.192.in-addr.arpa" IN {
        type master;
        file "10-168-192";
        allow-update {none;};
};

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



正解:
vim /var/named/cy.local

$TTL 86400
@   IN  SOA     dns.cy.local. root.cy.local. (
        0 ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)

@       IN      NS      dns.cy.local.
@       IN      A       192.168.10.13
dns     IN      A       192.168.10.13

反解:
vim /var/named/10.168.192.in-addr.arpa

$TTL 86400
@   IN  SOA     dns.cy.local. root.cy.local. (
        0  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)

@       IN      NS      dns.cy.local.
@       IN      PTR     cy.local.
dns      IN      A       192.168.10.13
13      IN      PTR     dns.cy.local.


#啟動
service named start

#開機自動啟動
chkconfig named on

Serial每修改一次正反解檔案必要遞增
常見錯誤在正解和反解,或檔案不存在的問題

參考資料:
http://www.unixmen.com/dns-server-installation-step-by-step-using-centos-6-3/