4.0.41.198.in-addr.arpa. 785 IN PTR a.root-servers.net. 0.3.0.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.3.a.b.3.0.5.0.1.0.0.2.ip6.arpa. 86400 IN PTR a.root-servers.net.
NS 资源记录
NS(即名称服务器)资源记录将域名映射到对其 DNS 区域具有权威的 DNS 名称服务器。区域的每个公开权威名称服务器必须具有 NS 记录。
1 2 3
example.com. 86400 IN NS classroom.example.com. 168.192.ip-addr.arpa. 86400 IN NS classroom.example.com. 9.0.e.1.4.8.4.6.2.e.d.f.ip6.arpa. 86400 IN NS classroom.example.com.
SOA 资源记录
SOA(即授权起始)资源记录提供关于 DNS 区域如何运作的信息。每个区域必须正好有一个 SOA 记录。
区域的 SOA 记录将区域的其中一个名称服务器指定为负责维护区域的资源记录的主名称服务器。它负责指定区域的管理内容的电子邮件地址。SOA 记录还指定了一个序列号和各种超时,供其他权威名称服务器用来确定何时从主名称服务器传输区域资源记录。
1
example.com. 86400 IN SOA classroom.example.com. root.classroom.example.com. 2015071700 3600 300 604800 60
MX 资源记录
MX 资源记录将域名映射到接受该域的电子邮件的邮件交换器。
此记录类型的数据是一个优先级编号(首选最低编号)
1 2 3
example.com. 86400 IN MX 10 classroom.example.com. example.com. 86400 IN MX 10 mail.example.com. example.com. 86400 IN MX 100 mailbackup.example.com.
_ldap._tcp.example.com. 86400 IN SRV 0 100 389 server0.example.com.
使用 Unbound 配置缓存名称服务器
Unbound是一款轻量级的DNS(域名系统)缓存和递归解析器,通常用于缓存服务器场景,缓存名称服务器在本地缓存中存储 DNS 查询结果,并且在 TTL 到期后从缓存中删除资源记录。通常设置缓存名称服务器以代表本地网络上的客户端执行查询。这降低了 Internet 上的 DNS 流量,从而极大提高了 DNS 名称解析的效率。随着缓存的增加,缓存名称服务器从其本地缓存中应答越来越多的客户端查询,从而提高 DNS 性能。
[root@servera ~]# unbound-control-setup setup in directory /etc/unbound generating unbound_server.key Generating RSA private key, 3072 bit long modulus (2 primes) ..........................................................++++ .....++++ e is 65537 (0x010001) generating unbound_control.key Generating RSA private key, 3072 bit long modulus (2 primes) ....................................++++ ......................................++++ e is 65537 (0x010001) create unbound_server.pem (self signed certificate) create unbound_control.pem (signed client certificate) Signature ok subject=CN = unbound-control Getting CA Private Key Setup success. Certificates created. Enable in unbound.conf file to use
检查是否有语法错误
1 2
[root@servera ~]# unbound-checkconf unbound-checkconf: no errors in /etc/unbound/unbound.conf
[root@servera ~]# vim /var/named/lixiaohui.cn.zone
一般来说,不需要在记录前面指定TTL,因为第一行写了1D
1 2 3 4 5 6 7 8 9 10 11 12 13
$TTL 1D lixiaohui.cn. IN SOA ns.lixiaohui.cn. 939958092.qq.com. ( 1 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum 1D IN NS ns.lixiaohui.cn. ns 1D IN A 172.25.250.10 lxh 30 IN A 172.25.250.100 30 IN AAAA 2001:db8:2020::5300 @ 20 IN MX 10 mail.lixiaohui.cn. mail 30 IN A 172.25.250.10
$TTL 1D lixiaohui.cn. IN SOA ns.lixiaohui.cn. 939958092.qq.com. ( 1 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum 1D IN NS ns.lixiaohui.cn. ns 1D IN A 172.25.250.10 lxh 30 IN A 192.168.8.100 30 IN AAAA 2001:db8:2020::5300 @ 20 IN MX 10 mail.lixiaohui.cn. mail 30 IN A 172.25.250.10 support.online 1H IN A 172.25.250.10
zone "lixiaohui.cn" IN { type slave; file "slaves/lixiaohui.cn.zone"; masters { 172.25.250.10; }; }; zone "250.25.172.in-addr.arpa" IN { type slave; file "slaves/lixiaohui.cn.ptr"; masters { 172.25.250.10; }; };
Aug 23 01:01:51 serverb.lab.example.com named[26633]: zone lixiaohui.cn/IN: Transfer started. Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: connected using 172.25.250.11#52091 Aug 23 01:01:51 serverb.lab.example.com named[26633]: zone lixiaohui.cn/IN: transferred serial 1 Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: Transfer status: success Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: Transfer completed: 1 messages, 9 records, 281 bytes, 0.002 secs (140500 bytes/sec) Aug 23 01:01:51 serverb.lab.example.com named[26633]: zone 250.25.172.in-addr.arpa/IN: Transfer started. Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of '250.25.172.in-addr.arpa/IN' from 172.25.250.10#53: connected using 172.25.250.11#33001 Aug 23 01:01:51 serverb.lab.example.com named[26633]: zone 250.25.172.in-addr.arpa/IN: transferred serial 1 Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of '250.25.172.in-addr.arpa/IN' from 172.25.250.10#53: Transfer status: success Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of '250.25.172.in-addr.arpa/IN' from 172.25.250.10#53: Transfer completed: 1 messages, 5 records, 197 bytes, 0.001 secs (197000 bytes/sec) Aug 23 01:02:01 serverb.lab.example.com named[26633]: resolver priming query complete
查询辅助DNS服务器
1 2 3 4
[root@serverb ~]# ll /var/named/slaves/ total 8 -rw-r--r--. 1 named named 326 Aug 23 01:01 lixiaohui.cn.ptr -rw-r--r--. 1 named named 480 Aug 23 01:01 lixiaohui.cn.zone
[root@servera ~]# cd /var/named/ [root@servera named]# vim lixiaohui.cn.zone [root@servera named]# cat lixiaohui.cn.zone $TTL 1D lixiaohui.cn. IN SOA ns.lixiaohui.cn. 939958092.qq.com. ( 2 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum 1D IN NS ns.lixiaohui.cn. ns 1D IN A 172.25.250.10 lxh 30 IN A 192.168.8.100 lxh-2 30 IN A 192.168.8.100 30 IN AAAA 2001:db8:2020::5300 @ 20 IN MX 10 mail.lixiaohui.cn. mail 30 IN A 172.25.250.10 support.online 1H IN A 172.25.250.10
[root@serverb ~]# cd /var/named/slaves/ [root@serverb slaves]# cat lixiaohui.cn.zone $ORIGIN . $TTL 86400 ; 1 day lixiaohui.cn IN SOA ns.lixiaohui.cn. 939958092.qq.com. ( 2 ; serial 86400 ; refresh (1 day) 3600 ; retry (1 hour) 604800 ; expire (1 week) 10800 ; minimum (3 hours) ) NS ns.lixiaohui.cn. $TTL 20 ; 20 seconds MX 10 mail.lixiaohui.cn. $ORIGIN lixiaohui.cn. $TTL 30 ; 30 seconds lxh A 192.168.8.100 lxh-2 A 192.168.8.100 AAAA 2001:db8:2020::5300 mail A 172.25.250.10 $TTL 86400 ; 1 day ns A 172.25.250.10 $TTL 3600 ; 1 hour support.online A 172.25.250.10
确认日志消息正确
1 2 3 4 5 6 7
Aug 23 04:05:50 serverb.lab.example.com named[864]: client @0x7fe308044c90 172.25.250.10#53572: received notify for zone 'lixiaohui.cn' Aug 23 04:05:50 serverb.lab.example.com named[864]: zone lixiaohui.cn/IN: notify from 172.25.250.10#53572: serial 2 Aug 23 04:05:50 serverb.lab.example.com named[864]: zone lixiaohui.cn/IN: Transfer started. Aug 23 04:05:50 serverb.lab.example.com named[864]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: connected using 172.25.250.11#46605 Aug 23 04:05:50 serverb.lab.example.com named[864]: zone lixiaohui.cn/IN: transferred serial 2 Aug 23 04:05:50 serverb.lab.example.com named[864]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: Transfer status: success Aug 23 04:05:50 serverb.lab.example.com named[864]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: Transfer completed: 1 messages, 10 records, 289 bytes, 0.001 secs (289000 bytes/sec)