DNS从服务的搭建
一、安装
[root@localhost~]# yum install bind
二、修改主配置文件
[root@localhost~]# cat /etc/named.conf
将以下三行注释掉
// listen-on port 53 { 127.0.0.1; }; // listen-on-v6 port 53 { ::1; }; // allow-query { localhost; };
三、将DNS指向本机
[root@localhost~]# 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; };
检查配置文件
[root@localhost~]# named-checkconf
五、修改主DNS服务器的/var/named/test.com.zone文件,添加从服务器信息
IN NS ns2 ns2 IN A 192.168.1.107
保存退出
检查配置文件
[root@localhost~]#named-checkzone “test.com” test.com.zone [root@localhost~]#rndc reload [root@localhost~]#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.103 ns2.test.com. 600 IN A 192.168.1.107
六、启动从服务器DNS服务
[root@localhost~]# service named start Generating/etc/rndc.key: [ OK ] Starting named:[ OK ]
启动成功后,发现在/var/named/slaves文件夹下有个test.com.zone文件
[root@localhostslaves]# ls test.com.zone
该文件就是从主服务器同步过来的
七、完成一次同步传输
[root@localhost~]# 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: +cmd test.com. 600 IN SOA dns.test.com.admin.test.com. 2014061601 7200 600 604800 21600 test.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.103 ftp.test.com. 600 IN CNAME www.test.com. imap.test.com. 600 IN A 192.168.1.101 mail.test.com. 600 IN A 192.168.1.103 ns2.test.com. 600 IN A 192.168.1.107 www.test.com. 600 IN A 192.168.1.100 www.test.com. 600 IN A 192.168.1.102 test.com. 600 IN SOA dns.test.com.admin.test.com. 2014061601 7200 600 604800 21600
DNS服务器之二:从服务器的实现,布布扣,bubuko.com
原文地址:http://eric1026.blog.51cto.com/4754515/1439726