首页 > 编程知识 正文

dns的默认缓存时间,版本6的DNS协议服务器地址

时间:2023-05-05 23:46:25 阅读:153641 作者:2691

管理RH358DNS和DNS服务器-使用unbound配置缓存名称服务器本章介绍如何使用unbound软件配置缓存DNS。 虽然在配置DNS方面部署在windows server上比较方便,但不可避免地会出现将来应该使用的场面,还是需要学习。

栏地址: https://blog.csdn.net/QQ _ 41765918/category _ 11532281.html

文章目录RH 358管理DNS和DNS服务器- -使用Unbound配置缓存名称服务器1 .安装和配置Unbound编辑Unbound配置文件启用缓存名称服务器2 . 闪存闪存安装unbound缓存3 .教科书练习1 .安装unbound。 2 .根据需要编辑server子句。 3 .生成私钥和服务器证书。 检查unbound配置文件的语法。 5 .配置防火墙以允许DNS通信。 启用并启动unbound服务。 7 .通过运行查询并检查缓存内容来验证缓存名称服务。 完成实验总结

DNS服务器软件: bind、powerdns、dnsmasq、unbound、coredns

安装和配置Unbound

缓存名称服务器将DNS查询的结果保存在本地缓存中,并在ttl过期时从缓存中删除资源记录。 通常,将缓存名称服务设置为代表本地网络上的客户端执行查询。 这样可以大大提高DNS名称解析的效率,减少互联网上的DNS流量。 随着缓存的增加,以及缓存名称服务器从本地缓存响应的客户端查询数量的增加,DNS性能将提高。 可以使用几个软件包配置缓存名称服务器,包括bind、dnsmasq和unbound。 在本节中,您将学习如何安装、配置和管理Unbound,它是启用了DNSSEC身份验证的更安全的缓存名称服务器。

安装unbound要将unbound配置为缓存名称服务器,请确保安装了unbound软件包:

[ root @ host~] # http://www.Sina.com /

编辑unbound配置文件,以使root用户编辑/etc/unbound/unbound.conf文件:如下所示

3358 www.Sina.com/interface :192.0.2.100 interface :20013360 db 8336010013360: f 0在缺省情况下,Unbound是本地主机网络要允许远程客户端使用Unbound作为缓存名称服务器,请使用/etc/unbound/unbound.conf的server子句中的interface选项来侦听网络接口可以指定多个接口命令。

yum install unbound

如果将interface设置为0.0.0.0或:0 (侦听所有网络接口),则必须将interface-automatic设置为yes。 否则,将界面自动设置为no。

如果libvirtd服务在与Unbound相同的计算机上运行,并且尝试绑定到所有接口,Unbound可能无法启动。 这是因为,缺省情况下,Libvirtd在连接到虚拟网络的本地接口的53个端口(UDP和TCP DNS服务器端口)上运行dnsmasq

在server子句中,定义Unbound将侦听的网络接口。缺省情况下,unbound拒绝除localhost之外的所有客户端的递归查询。 在/etc/unbound/unbound .conf的server子句中,使用access-control选项指定可以执行递归查询的客户端。 可以指定网络地址或IP地址,最匹配的获胜。 最方便的三个设置为重要:,访问许可,允许或阻止客户端访问。,阻止访问并向客户端发送DNS拒绝错误,allow

access-control :172.25.0.0/24 allow access-control 33602001: db 8336010013360:/32 allow access-control

将access-control配置为使目标客户端以外的主机不使用缓存名称服务器递归。 如果允许internet上的任何主机使用您的服务器递归查询,攻击者就可以使用它对第三方执行DNS扩展分布式拒绝服务攻击(DDOS )。

refuse如果此名称服务器无权访问internet,但您有权访问internet的名称服务器,则可能需要此名称服务器。 这样,也可以将内部域的查询直接发送到该域的权威名称服务。

在/etc/unbound/unbound.conf中,创建forward-zone子句以指定要传输的域和查询的DNS服务器。 将name值设置为“.”以转发所有查询。 使用forward-host选项以主机名指定转发区域的DNS服务器,或使用forward-addr选项通过IP

地址指定转发区域的DNS服务器。

forward-zone: name: "." forward-addr: 172.25.254.254 禁用特定未签名区域的DNSSEC****验证(可选)。

默认情况下,unbound对接收到的所有DNS响应进行DNSSEC验证。通常希望它这样做,但有时会有一个未正确签名的内部域,因此无法通过DNSSEC验证。

/etc/unbound/unbound.conf的server子句中的domain-insecure选项指定了需要跳过DNSSEC验证的域。

domain-insecure: example.com

警告:不要仅仅为了解决DNS解析中未解释的问题而禁用DNSSEC验证。DNSSEC失败可能表明正在接收被正确拒绝的欺骗响应。

保存配置文件/etc/unbound/unbound.conf。

生成私钥和服务器证书。

[root@host ~]# unbound-control-setupsetup in directory /etc/unboundgenerating unbound_server.keyGenerating RSA private key, 3072 bit long modulus (2 primes)..........................................................++++.....++++e is 65537 (0x010001)generating unbound_control.keyGenerating 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 oksubject=CN = unbound-controlGetting CA Private KeySetup success. Certificates created. Enable in unbound.conf file to use# 检查/etc/unbound/unbound.conf配置文件的语法错误。[root@host ~]# unbound-checkconfunbound-checkconf: no errors in /etc/unbound/unbound.conf 启用缓存名称服务器

配置防火墙允许DNS流量。如果使用firewalld,可以配置它以允许dns服务。

[root@host ~]# firewall-cmd --permanent --add-service=dnssuccess[root@host ~]# firewall-cmd --reloadsuccess# 启动并开机启用Unbound。[root@host ~]# systemctl enable --now unbound 2. 管理Unbound

安装了Unbound DNS服务器后,管理员有时需要操作它的缓存。unbound-control实用程序管理unbound服务器的缓存。

转储和加载unbound缓存

缓存名称服务器的管理员在解决DNS问题时可能需要转储缓存数据,比如那些由过时的资源记录引起的问题。转储Unbound DNS服务器的缓存,请使用unbound-control实用程序配合dump_cache子命令。

[root@host ~]# unbound-control dump_cacheSTART_RRSET_CACHE;rrset 86395 1 0 3 3classroom.example.com. 86395 IN A 172.25.254.254;rrset 86395 1 0 7 3example.com. 86395 IN NS classroom.example.com.;rrset 86395 1 0 8 3example.com. 86395 IN A 172.25.254.254END_RRSET_CACHESTART_MSG_CACHEmsg example.com. IN A 33152 1 86395 3 1 1 1example.com. IN A 0example.com. IN NS 0classroom.example.com. IN A 0END_MSG_CACHEEOF

使用dump_cache执行unbinding -control命令将缓存以文本格式转储到stdout。这个输出可以被定向到一个文件中进行存储,如果需要的话,可以使用unbound-control load_cache加载回缓存中。unbound-control load_cache命令从stdin读取数据来填充缓存。

[root@host ~]# unbound-control load_cache < dump.outok 刷新unbound缓存

缓存名称服务器的管理员可能还需要定期从缓存中清除过时的资源记录。缓存中的错误和过时的资源记录会阻止已改正的对应记录对客户端可用,直到资源记录上的TTL过期。与等待TTL过期不同,您可以通过对记录执行unbound-control flush来清除缓存中的过时记录:

[root@host ~]# unbound-control flush www.example.comok# 使用flush_zone子命令执行unbound-control以清除Unbound DNS服务器上属于某个域的所有资源记录。[root@host ~]# unbound-control flush_zone example.comok removed 3 rrsets, 1 messages and 0 key entries 3. 课本练习

[student@workstation ~]$ lab dns-unbound start

1. 安装unbound。 [root@servera ~]# yum install unbound 2. 按要求编辑server子句。 在172.25.250.10接口上监听。允许来自172.25.250.0/24子网进行查询。免example.com区域的DNSSEC验证。将所有查询转发到172.25.250.254。 [root@servera ~]# vim /etc/unbound/unbound.confinterface: 172.25.250.10access-control: 172.25.250.0/24 allowdomain-insecure: "example.com"forward-zone: name: . forward-addr: 172.25.250.254 3. 生成私钥和服务器证书。 [root@servera ~]# unbound-control-setupsetup in directory /etc/unboundgenerating unbound_server.keyGenerating RSA private key, 3072 bit long modulus (2 primes)...........++++.......++++e is 65537 (0x010001)generating unbound_control.keyGenerating 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 oksubject=CN = unbound-controlGetting CA Private KeySetup success. Certificates created. Enable in unbound.conf file to use 4. 检查unbound配置文件的语法。 [root@servera ~]# unbound-checkconfunbound-checkconf: no errors in /etc/unbound/unbound.conf 5. 配置防火墙允许DNS流量。 [root@servera ~]# firewall-cmd --permanent --add-service=dnssuccess[root@servera ~]# firewall-cmd --reloadsuccess 6. 启用并启动unbound服务。 [root@servera ~]# systemctl enable --now unboundCreated symlink /etc/systemd/system/multi-user.target.wants/unbound.service → /usr/lib/systemd/system/unbound.service. 7. 通过执行查询和检查缓存的内容来验证缓存名称服务。 [root@servera ~]# unbound-control dump_cacheSTART_RRSET_CACHEEND_RRSET_CACHESTART_MSG_CACHEEND_MSG_CACHEEOF[student@workstation ~]$ dig @servera.lab.example.com A workstation.lab.example.com...........workstation.lab.example.com. 600 IN A 172.25.250.9[student@workstation ~]$ dig @servera.lab.example.com A servera.lab.example.com............servera.lab.example.com. 600 IN A 172.25.250.10# 在服务器上,再次转储缓存。您应该在缓存中看到查询的记录。[root@servera ~]# unbound-control dump_cache............msg workstation.lab.example.com. IN A 33152 1 587 3 1 1 1workstation.lab.example.com. IN A 0lab.example.com. IN NS 0bastion.lab.example.com. IN A 0msg net. IN DNSKEY 33152 1 78675 0 1 0 0net. IN DNSKEY 0END_MSG_CACHEEOF[root@servera ~]# unbound-control flush workstation.lab.example.comok[root@servera ~]# unbound-control dump_cache | grep workstation 完成实验

[student@workstation ~]$ lab dns-unbound finish

总结 介绍如何安装和配置Unbound。管理Unbound。若喜欢ssdwk的文章,顺手点个赞。也可点个关注,因为后续会不断上干货。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。