2.CentOS6.5下的DNS主从区域传送配置
接着《1.CentOS6.5下的基础DNS配置》来说,主从区域传送只能让从服务器来进行传送,不给任何人传送,我们看看上一章节《1.CentOS6.5下的基础DNS配置》是否可传送:
[root@localhost etc]# dig -t axfr itox.com.cn @192.168.100.3
;; Connection to 192.168.100.3#53(192.168.100.3) for itox.com.cn failed: host unreachable.
[root@localhost etc]# dig -t axfr itox.com.cn @192.168.100.3
; <<>> DiG 9.9.4-RedHat-9.9.4-73.el7_6 <<>> -t axfr itox.com.cn @192.168.100.3
;; global options: +cmd
itox.com.cn. 600 IN SOA ns1.itox.com.cn. admin.itox.com.cn. 2019040701 7200 540 259200 36000
itox.com.cn. 600 IN NS ns1.itox.com.cn.
itox.com.cn. 600 IN MX 10 mail.itox.com.cn.
*.itox.com.cn. 600 IN A 192.168.100.3
ftp.itox.com.cn. 600 IN A 192.168.100.25
kali2.itox.com.cn. 600 IN A 192.168.100.22
kali3.itox.com.cn. 600 IN A 192.168.100.23
mail.itox.com.cn. 600 IN A 192.168.100.24
nfs.itox.com.cn. 600 IN A 192.168.100.28
ns1.itox.com.cn. 600 IN A 192.168.100.3
radius.itox.com.cn. 600 IN CNAME ftp.itox.com.cn.
samba.itox.com.cn. 600 IN A 192.168.100.27
www.itox.com.cn. 600 IN A 192.168.100.26
itox.com.cn. 600 IN SOA ns1.itox.com.cn. admin.itox.com.cn. 2019040701 7200 540 259200 36000
;; Query time: 2 msec
;; SERVER: 192.168.100.3#53(192.168.100.3)
;; WHEN: 日 4月 07 22:25:18 CST 2019
;; XFR size: 14 records (messages 1, bytes 343)
这里我们看到是能够被任何人传送的,因此我们在配置DNS主从传送的时候还需要改动一下named.conf只能被从服务器(这里实验指定192.168.100.24为从服务器),开始配置之前,主从服务器都改一下/etc/sysconfig/named文件,默认里面全部是注释的,加一行在末尾:OPTIONS="-4",去除去IPv6的解析,只解析IPv4,OPTIONS选项的值可以是:whatever、-4、-6中的一个,不然在主从传送过程中会看到一堆的:named network unreachable resolving,主从都要改,记得!
区域传送DNS主服务器named.conf如下,有改动的位置专注标红:
options {
directory "/var/named";
#recursion yes;
allow-recursion { 192.168.100.0/24; }; #这里只允许给192.168.100.0/24的网段递归查询,实际中几乎不会用
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-transfer { none; };
};
zone "0.0.127" IN {
type master;
file "named.loopback";
allow-transfer { none; };
};
zone "itox.com.cn" IN {
type master;
file "itox.com.cn.zone";
allow-transfer { 192.168.100.24; };
};
zone "100.168.192.in-addr.arpa" IN {
type master;
file "192.168.100.zone";
allow-transfer { 192.168.100.24; };
};
把主服务器的named.conf复制到从服务器相同的位置,然后改动部分内容,就可以启动服务了,从服务器named.conf如下:
options {
directory "/var/named";
#recursion yes;
allow-recursion { 192.168.100.0/24; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-transfer { none; };
};
zone "0.0.127" IN {
type master;
file "named.loopback";
allow-transfer { none; };
};
zone "itox.com.cn" IN {
type slave; #这里改成从哦
file "slaves/itox.com.cn.zone"; #传送过来的文件放在slaves目录下,这个文件夹named用户是用权限写入的
masters { 192.168.100.3; }; #指定主服务器在哪里
masterfile-format text; #这个写上,不然你看到的主服务器传送过来的/var/named/slaves/itox.com.cn的正反向文件是乱码,raw格式的,无法读。
allow-transfer { none; }; #我就是从了,我就不给别人传送了
};
zone "100.168.192.in-addr.arpa" IN {
type slave;
file "slaves/192.168.100.zone";
masterfile-format text;
masters { 192.168.100.3; };
allow-transfer { none; };
};
好了,配置完成,验证办法很简单,直接看看/var/named/slaves目录下,文件过来了没有。