标签:通知 同步 添加 size strong aliyun 内容 ann cal
主dns:CentOS6.8-01 172.24.8.10 linuxmaster.aliyun.com
辅dns:CentOS6.8-02 172.24.8.11 linuxslave.aliyun.com
yum+www服务器:CentOS7-03 172.24.8.30 mirrors.aliyun.com
client:CentOS6.8-03 172.24.8.20
Domain Name:aliyun.com
1 [root@linuxmaster ~]# yum -y install bind
1 [root@linuxmaster ~]# cat /etc/named.conf 2 …… 3 options { 4 listen-on port 53 { 127.0.0.1; }; 5 listen-on-v6 port 53 { ::1; }; 6 directory "/var/named"; #存放区域文件根目录,下面给出的相对路径都是相对此目录 7 dump-file "/var/named/data/cache_dump.db"; 8 statistics-file "/var/named/data/named_stats.txt"; 9 memstatistics-file "/var/named/data/named_mem_stats.txt"; 10 allow-query { localhost; }; #允许哪些主机查询 11 recursion yes; #是否允许递归查询 12 13 dnssec-enable yes; 14 dnssec-validation yes; 15 16 /* Path to ISC DLV key */ 17 bindkeys-file "/etc/named.iscdlv.key"; 18 19 managed-keys-directory "/var/named/dynamic"; 20 }; 21 22 logging { #定义日志 23 channel default_debug { 24 file "data/named.run"; 25 severity dynamic; 26 }; 27 }; 28 29 zone "." IN { #定义根区域文件名称 30 type hint; 31 file "named.ca"; #相对路径,即可/var/named/named.ca 32 }; 33 34 include "/etc/named.rfc1912.zones"; #定义区域配置文件,若要新增也可以在此使用include 35 include "/etc/named.root.key"; #根区域的key文件,与事务签名相关 36 注释以下三行—— 37 //listen-on port 53 { 127.0.0.1; }; 38 //listen-on-v6 port 53 { ::1; }; 39 //allow-query { localhost; }; 40 [root@linuxmaster ~]# service named start #启动named服务
ss -taunl | grep "53" 或 netstat -tlun验证服务正常启动
1 [root@linuxmaster ~]# vi /etc/named.conf #在zone文件中增加区域 2 …… 3 zone "aliyun.com" IN { 4 type master; 5 file "aliyun.com.zone"; 6 }; 7 ……
1 [root@linuxmaster ~]# cd /var/named/ 2 [root@linuxmaster named]# cp /var/named/named.localhost /var/named/aliyun.com.zone 3 [root@linuxmaster named]# vi /var/named/aliyun.com.zone 4 $TTL 300; 5 @ IN SOA linuxmaster.aliyun.com. admin.aliyun.com. ( 6 2017051720 7 1H 8 5M 9 7D 10 3D ) 11 IN NS linuxmaster 12 IN MX 20 MX 13 linuxmaster IN A 172.24.8.10 14 www IN A 172.24.8.30 15 mirrors IN A 172.24.8.30 16 ftp IN CNAME www 17 [root@linuxmaster ~]# named-checkconf #检查配置文件 18 [root@linuxmaster named]# named-checkzone "aliyun.com.zone" /var/named/aliyun.com.zone 19 zone aliyun.com.zone/IN: loaded serial 2017051720 20 OK
1 [root@linuxmaster ~]# chmod 640 /var/named/aliyun.com.zone 2 [root@linuxmaster ~]# chown root:named /var/named/aliyun.com.zone 3 注意:确保主配置文件和各区域文件权限为640,属主为root,属组为named。 4 [root@linuxmaster ~]# service named restart
1 [root@linuxmaster ~]# service iptables stop 2 [root@linuxmaster ~]# setenforce 0 3 [root@linuxmaster ~]# service named restart
将dns修改为主dns服务器地址,之后ping linuxmaster.aliyun.com测试。
正向解析与反向解析各自采用不同的解析库,一台DNS服务器可以只有正向解析库或只有反向解析库,也可以同时提供正向/反向解析。
反向区域的区域名称格式:
ReverseIP.in-addr.arpa.
例如:假设网络地址为172.16.100.1 那么规则命名为100.16.172.in-addr.arpa
1 [root@linuxmaster ~]# vi /etc/named.conf 2 …… 3 zone "8.24.172.in-addr.arpa" IN { 4 type master; 5 file "8.24.172.zone"; 6 }; 7 ……
1 [root@linuxmaster ~]# /var/named/8.24.172.zone 2 $TTL 300; 3 @ IN SOA linuxmaster.aliyun.com. admin.aliyun.com. ( 4 2017051720 5 1H 6 5M 7 7D 8 3D ) 9 IN NS linuxmaster.aliyun.com. 10 8.10 IN PTR linuxmaster.aliyun.com. 11 8.30 IN PTR www.aliyun.com. 12 8.30 IN PTR mirrors.aliyun.com. 13 8.10 IN PTR mx.aliyun.com.
注意:
反向解析不需要CNAME记录,且MX记录决不允许出现在反向解析库里;
8.10 ip地址没写全会自动从主配置文件中定义的区域名“24.172.in-addr.arpa”,没写全最后面不需要加.
1 [root@linuxmaster ~]# named-checkconf #检查配置文件 2 [root@linuxmaster ~]# named-checkzone "aliyun.com.zone" /var/named/aliyun.com.zone 3 zone aliyun.com.zone/IN: loaded serial 2017051720 4 OK 5 [root@linuxmaster ~]# named-checkzone "aliyun.com.zone" /var/named/8.24.172.zone 6 zone aliyun.com.zone/IN: loaded serial 2017051720 7 OK
1 [root@linuxmaster ~]# chmod 640 /var/named/24.172.zone 2 [root@linuxmaster ~]# chown root:named /var/named/24.172.zone 3 注意:确保主配置文件和各区域文件权限为640,属主为root,属组为named。 4 [root@linuxmaster ~]# service named restart
1 [root@linuxmaster ~]# service iptables stop 2 [root@linuxmaster ~]# setenforce 0 3 [root@linuxmaster ~]# service named restart
将dns修改为主dns服务器地址,之后在Windows客户端使用nslookup测试。
辅助DNS是针对区域来说的,如果有多台DNS服务器,必须为每个DNS服务器建立NS记录,否则主DNS将不向其发送通知。
1 zone “区域名称” IN { 2 type slave; #区域类型为辅助 3 file "slaves/ZONE_NAME.zone"; #区域文件必须保存在slaves目录下,放在其他目录没有权限 4 masters { #指出主服务器是谁,注意:花括号前后要有一个空格 5 MASTER_DNS_IP; 6 MASTER_DNS2_IP; 7 }; 8 };
1 [root@linuxslave ~]# yum -y install bind
1 [root@linuxslave ~]# vi /etc/named.rfc1912.zones #建议添加在named.rfc1912.zones里 2 …… 3 zone "aliyun.com" IN { 4 type slave; 5 file "slaves/aliyun.com.zone"; 6 masters { 172.24.8.10; }; #主DNS的地址 7 }; 8 zone "8.24.172-addr.arpa" IN { 9 type slave; 10 file "slaves/24.8.172.zone"; 11 masters { 172.24.8.10; }; 12 }; 13 [root@linuxslave ~]# named-checkconf #检查配置
1 [root@linuxslave ~]# service iptables stop 2 [root@linuxslave ~]# setenforce 0 3 [root@linuxslave ~]# service named restart
1 [root@linuxmaster ~]# vi /var/named/aliyun.com.zone 2 $TTL 300; 3 @ IN SOA linuxmaster.aliyun.com. admin.aliyun.com. ( 4 2017051720 5 1H 6 5M 7 7D 8 3D ) 9 IN NS linuxmaster 10 IN NS linuxslave 11 IN MX 20 MX 12 linuxmaster IN A 172.24.8.10 13 linuxslave IN A 172.24.8.11 14 www IN A 172.24.8.30 15 mirrors IN A 172.24.8.30 16 mx IN A 172.24.8.10 17 ftp IN CNAME www
1 [root@linuxmaster ~]# vi /var/named/8.24.172.zone 2 $TTL 300; 3 @ IN SOA linuxmaster.aliyun.com. admin.aliyun.com. ( 4 2017051720 5 1H 6 5M 7 7D 8 3D ) 9 IN NS linuxmaster.aliyun.com. 10 IN NS linuxslave.aliyun.com. 11 8.10 IN PTR linuxmaster.aliyun.com. 12 8.11 IN PTR linuxslave.aliyun.com. 13 8.30 IN PTR www.aliyun.com. 14 8.30 IN PTR mirrors.aliyun.com. 15 8.10 IN PTR mx.aliyun.com.
1 [root@linuxmaster ~]# named-checkconf #检查配置文件 2 [root@linuxmaster ~]# named-checkzone "aliyun.com.zone" /var/named/aliyun.com.zone 3 zone aliyun.com.zone/IN: loaded serial 2017051720 4 OK 5 [root@linuxmaster ~]# named-checkzone "aliyun.com.zone" /var/named/8.24.172.zone 6 zone aliyun.com.zone/IN: loaded serial 2017051720 7 OK 8 [root@linuxmaster ~]# service named restart
查看主DNS往辅助DNS的数据同步情况
1 [root@linuxslave ~]# yum -y install bind-utils 2 #安装客户端 3 [root@linuxslave ~]# dig -t axfr aliyun.com @172.24.8.10 #查看辅助dns同步情况
1 [root@linuxslave ~]# cat /var/named/slaves/aliyun.com.zone
注意:辅助DNS资源记录是从主DNS同步过来的,不能手动更改。
Windows客户端检测。
总结:
标签:通知 同步 添加 size strong aliyun 内容 ann cal
原文地址:https://www.cnblogs.com/itzgr/p/9888602.html