標籤:dns bind
DNS從服務的搭建
一、安裝
[[email protected]~]# yum install bind
二、修改主設定檔
[[email protected]~]# cat /etc/named.conf
將以下三行注釋掉
// listen-on port 53 { 127.0.0.1; };// listen-on-v6 port 53 { ::1; };// allow-query { localhost; };
三、將DNS指向本機
[[email protected]~]# vim /etc/resolv.conf ;generated by /sbin/dhclient-script nameserver 192.168.1.107
四、在/etc/named.rfc1912.zones檔案中定義從屬的域
zone"test.com" IN { type slave; file "slave/test.com.zone"; masters { 192.168.1.109; };
檢查設定檔
[[email protected]~]# named-checkconf
五、修改主DNS伺服器的/var/named/test.com.zone檔案,添加從伺服器資訊
IN NS ns2ns2 IN A 192.168.1.107
儲存退出
檢查設定檔
[[email protected]~]#named-checkzone “test.com” test.com.zone[[email protected]~]#rndc reload[[email protected]~]#dig –t NS test.com ;<<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> -tNS test.com;; globaloptions: +cmd;; Got answer:;;->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19243;; flags: qr aard ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2 ;; QUESTION SECTION:;test.com. IN NS ;; ANSWERSECTION:test.com. 600 IN NS ns2.test.com.test.com. 600 IN NS dns.test.com. ;; ADDITIONALSECTION:dns.test.com. 600 IN A 192.168.1.103ns2.test.com. 600 IN A 192.168.1.107
六、啟動從伺服器DNS服務
[[email protected]~]# service named startGenerating/etc/rndc.key: [ OK ]Starting named:[ OK ]
啟動成功後,發現在/var/named/slaves檔案夾下有個test.com.zone檔案
[[email protected]]# lstest.com.zone
該檔案就是從主伺服器同步過來的
七、完成一次同步傳輸
[[email protected]~]# dig -t axfr test.com @192.168.1.103 ;<<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> -taxfr test.com @192.168.1.103;; globaloptions: +cmdtest.com. 600 IN SOA dns.test.com.admin.test.com. 2014061601 7200 600 604800 21600test.com. 600 IN NS dns.test.com.test.com. 600 IN NS ns2.test.com.test.com. 600 IN MX 10 mail.test.com.dns.test.com. 600 IN A 192.168.1.103ftp.test.com. 600 IN CNAME www.test.com.imap.test.com. 600 IN A 192.168.1.101mail.test.com. 600 IN A 192.168.1.103ns2.test.com. 600 IN A 192.168.1.107www.test.com. 600 IN A 192.168.1.100www.test.com. 600 IN A 192.168.1.102test.com. 600 IN SOA dns.test.com.admin.test.com. 2014061601 7200 600 604800 21600