redhat 5 dns配置示例一

wisdomone1發表於2013-05-06

--dns配置詳解

http://space.itpub.net/?uid-9094533-action-viewspace-itemid-73572

 

 

---啟動dns named失敗
[root@rhel5 named]# service named start
Starting named:                                            [FAILED]

---檢視系統日誌
[root@rhel5 log]# tail -50 /var/log/messages
May  6 11:01:39 rhel5 named[5497]: could not configure root hints from 'named.root': file not found

---進入如下目錄
[root@rhel5 etc]# cd /var/named

--複製一個提示找不到的檔案
[root@rhel5 named]# cp -a named.local named.root

--啟動成功
[root@rhel5 named]# service named start
Starting named:                                            [  OK  ]
[root@rhel5 named]# ps -ef|grep name
named     5539     1  0 11:05 ?        00:00:00 /usr/sbin/named -u named
root      5550  5447  0 11:05 pts/1    00:00:00 grep name

 

 

 

 

 

 

 

dns正向解析配置如下

----------------------------------------------------

[root@rhel5 named]# more /etc/named.conf
// Red Hat BIND Configuration Tool
//
// Default initial "Caching Only" name server configuration
//

//options為一個節,指定dns全域性配置資訊
options {
        directory "/var/named"; //directory指定域配置檔案所在的目錄
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        /*
         * If there is a firewall between you and nameservers you want
         * to talk to, you might need to uncomment the query-source
         * directive below.  Previous versions of BIND always asked
         * questions using port 53, but BIND 8.1 uses an unprivileged
         * port by default.
         */
         // query-source address * port 53;
};

//zone為專門的域配置檔案的節,指定具體的域配置檔名稱相關資訊
zone "." IN {
        type hint;
        file "named.root";--file指定域配置檔名稱,如無此檔案dns named會失敗
};

zone "localdomain." IN {
        type master;
        file "localdomain.zone";
        allow-update { none; };
};
zone "sina.com" IN { //sina.com為測試的域
        type master;
        file "sina.com.zone";//域配置檔名稱
        allow-update { none; };
};


zone "localhost." IN {
        type master;
        file "localhost.zone";
        allow-update { none; };
};

zone "0.0.127.in-addr.arpa." IN {
        type master;
        file "named.local";
        allow-update { none; };
};

zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." IN {
        type master;
        file "named.ip6.local";
        allow-update { none; };
};

zone "255.in-addr.arpa." IN {
        type master;
        file "named.broadcast";
        allow-update { none; };
};

zone "0.in-addr.arpa." IN {
        type master;
        file "named.zero";
        allow-update { none; };
};

include "/etc/rndc.key";

//如下為具體的域配置檔案
[root@rhel5 named]# more /var/named/sina.com.zone
$TTL    86400
@               IN SOA  ns.sina.com  root.sina.com (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS           ns.sina.com
ns              IN A            192.168.1.1
www             IN CNAME        ns.sina.com
mail            IN CNAME        ns.sina.com
localhost       IN A            127.0.0.1

[root@rhel5 named]# clear
[root@rhel5 named]# more /etc/named.conf
// Red Hat BIND Configuration Tool
//
// Default initial "Caching Only" name server configuration
//

options {
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        /*
         * If there is a firewall between you and nameservers you want
         * to talk to, you might need to uncomment the query-source
         * directive below.  Previous versions of BIND always asked
         * questions using port 53, but BIND 8.1 uses an unprivileged
         * port by default.
         */
         // query-source address * port 53;
};

zone "." IN {
        type hint;
        file "named.root";
};

zone "localdomain." IN {
        type master;
        file "localdomain.zone";
        allow-update { none; };
};
zone "sina.com" IN {
        type master;
        file "sina.com.zone";
        allow-update { none; };
};


zone "localhost." IN {
        type master;
        file "localhost.zone";
        allow-update { none; };
};

zone "0.0.127.in-addr.arpa." IN {
        type master;
        file "named.local";
        allow-update { none; };
};

zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." IN {
        type master;
        file "named.ip6.local";
        allow-update { none; };
};

zone "255.in-addr.arpa." IN {
        type master;
        file "named.broadcast";
        allow-update { none; };
};

zone "0.in-addr.arpa." IN {
        type master;
        file "named.zero";
        allow-update { none; };
};

include "/etc/rndc.key";
[root@rhel5 named]#

 

[root@rhel5 named]# more /var/named/sina.com.zone
$TTL    86400
@               IN SOA  ns.sina.com  root.sina.com (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS           ns.sina.com
ns              IN A            192.168.1.1
www             IN CNAME        ns.sina.com
mail            IN CNAME        ns.sina.com
localhost       IN A            127.0.0.1


[root@rhel5 named]# nslookup ns.sina.com
Server:         192.168.1.1
Address:        192.168.1.1#53

Name:   ns.sina.com
Address: 192.168.1.1

[root@rhel5 named]#

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-759864/,如需轉載,請註明出處,否則將追究法律責任。

相關文章