RH358管理DNS和DNS服务器–使用Unbound配置缓存名称服务器

本章节介绍使用unbound软件配置缓存DNS。虽说配置DNS方面还是在windows server上部署更加方便,但难免出现日后需要使用的场景,还是需要学习。

专栏地址:https://blog.csdn.net/qq_41765918/category_11532281.html

文章目录

  • RH358管理DNS和DNS服务器--使用Unbound配置缓存名称服务器
    • 1. 安装和配置Unbound
      • 安装unbound
      • 编辑unbound配置文件
      • 启用缓存名称服务器
    • 2. 管理Unbound
      • 转储和加载unbound缓存
      • 刷新unbound缓存
    • 3. 课本练习
      • 1. 安装unbound。
      • 2. 按要求编辑server子句。
      • 3. 生成私钥和服务器证书。
      • 4. 检查unbound配置文件的语法。
      • 5. 配置防火墙允许DNS流量。
      • 6. 启用并启动unbound服务。
      • 7. 通过执行查询和检查缓存的内容来验证缓存名称服务。
      • 完成实验
    • 总结

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

1. 安装和配置Unbound

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

安装unbound

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

[root@host ~]# yum install unbound

编辑unbound配置文件

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

  • 在server子句中,定义Unbound将侦听的网络接口。
interface: 192.0.2.100
interface: 2001:db8:1001::f0

默认情况下,Unbound只侦听本地主机网络接口。要允许远程客户端使用Unbound作为缓存名称服务器,请使用/etc/unbound/unbound.conf中server子句中的interface选项来指定要侦听的网络接口。您可以指定多个接口指令。

重要:

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

如果libvirtd服务与Unbound运行在同一台机器上,并且试图绑定到所有接口,Unbound可能不会启动。这是因为,默认情况下,Libvirtd在连接到其虚拟网络的本地接口的53端口(UDP和TCP的DNS服务器端口)上运行dnsmasq

  • 允许或阻止客户端访问。

默认情况下,unbound拒绝来自除localhost以外的所有客户机的递归查询。在/etc/unbound/unbound .conf的server子句中,使用access-control选项来指定哪些客户端可以进行递归查询。可以指定网络地址或IP地址,匹配最多的将获胜。最有用的三种设置是allow,,允许访问,refuse,阻止访问并向客户端发送DNS拒绝错误,deny,阻止访问并根本不发送响应,

access-control: 172.25.0.0/24 allow
access-control: 2001:db8:1001::/32 allow
access-control: 10.0.0.0/8 refuse

重要:

配置一个access-control来禁止除您的目标客户端以外的主机使用缓存名称服务器的递归。如果你允许互联网上的任何主机使用你的服务器进行递归查询,它可以被攻击者用来对第三方执行DNS放大分布式拒绝服务攻击(DDOS)。

  • 将查询转发到另一个缓存名称服务器(可选)。

如果此名称服务器不能访问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-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# 检查/etc/unbound/unbound.conf配置文件的语法错误。
[root@host ~]# unbound-checkconf
unbound-checkconf: no errors in /etc/unbound/unbound.conf

启用缓存名称服务器

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

[root@host ~]# firewall-cmd --permanent --add-service=dns
success
[root@host ~]# firewall-cmd --reload
success# 启动并开机启用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_cache
START_RRSET_CACHE
;rrset 86395 1 0 3 3
classroom.example.com. 86395 IN A 172.25.254.254
;rrset 86395 1 0 7 3
example.com. 86395 IN NS classroom.example.com.
;rrset 86395 1 0 8 3
example.com. 86395 IN A 172.25.254.254
END_RRSET_CACHE
START_MSG_CACHE
msg example.com. IN A 33152 1 86395 3 1 1 1
example.com. IN A 0
example.com. IN NS 0
classroom.example.com. IN A 0
END_MSG_CACHE
EOF

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

[root@host ~]# unbound-control load_cache < dump.out
ok

刷新unbound缓存

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

[root@host ~]# unbound-control flush www.example.com
ok# 使用flush_zone子命令执行unbound-control以清除Unbound DNS服务器上属于某个域的所有资源记录。
[root@host ~]# unbound-control flush_zone example.com
ok 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.conf
interface: 172.25.250.10
access-control: 172.25.250.0/24 allow
domain-insecure: "example.com"
forward-zone:name: .      forward-addr: 172.25.250.254

3. 生成私钥和服务器证书。

[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

4. 检查unbound配置文件的语法。

[root@servera ~]# unbound-checkconf
unbound-checkconf: no errors in /etc/unbound/unbound.conf

5. 配置防火墙允许DNS流量。

[root@servera ~]# firewall-cmd --permanent --add-service=dns
success
[root@servera ~]# firewall-cmd --reload
success

6. 启用并启动unbound服务。

[root@servera ~]# systemctl enable --now unbound
Created symlink /etc/systemd/system/multi-user.target.wants/unbound.service → /usr/lib/systemd/system/unbound.service.

7. 通过执行查询和检查缓存的内容来验证缓存名称服务。

[root@servera ~]# unbound-control dump_cache
START_RRSET_CACHE
END_RRSET_CACHE
START_MSG_CACHE
END_MSG_CACHE
EOF[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 1
workstation.lab.example.com. IN A 0
lab.example.com. IN NS 0
bastion.lab.example.com. IN A 0
msg net. IN DNSKEY 33152 1 78675 0 1 0 0
net. IN DNSKEY 0
END_MSG_CACHE
EOF[root@servera ~]# unbound-control flush workstation.lab.example.com
ok[root@servera ~]# unbound-control dump_cache | grep workstation

完成实验

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

总结

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

RH358管理DNS和DNS服务器--使用Unbound配置缓存名称服务器相关推荐

  1. 方舟服务器物理机配置,方舟云服务器要什么配置

    方舟云服务器要什么配置 内容精选 换一换 当用户已在ECS服务购买GPU加速型云服务器,并且想在该云服务器上运行应用时,可以通过纳管的方式将该云服务器纳入VR云渲游平台管理.登录控制台,在服务列表中选 ...

  2. ntp协议客户端服务器模式,思科配置NTP客户端服务器模式

    思科配置NTP客户端服务器模式 内容精选 换一换 该操作指导安装工程师安装MRS集群所有服务(不包含Flume)的客户端.MRS针对不同服务提供了Shell脚本,供开发维护人员在不同场景下登录其对应的 ...

  3. 思科恢复服务器上的配置信息,思科服务器的配置方法

    思科服务器的配置方法 内容精选 换一换 安装依赖时,使用pip3.7.5 install xxx命令安装相关软件时提示无法连接网络,且提示"Could not find a version ...

  4. 数据库及服务器操作系统基本配置,数据库及服务器操作系统基本配置

    数据库及服务器操作系统基本配置 内容精选 换一换 华为云云堡垒机服务帮助中心,为用户提供产品介绍.快速入门.用户指南.最佳实践.常见问题.视频帮助.技术白皮书等技术文档,帮助您快速上手使用云堡垒机服务 ...

  5. ASE无线认证服务器,华为ac配置portal认证服务器

    华为ac配置portal认证服务器 内容精选 换一换 配置云AP的SSID时支持的认证方式多达13种,但是常用且推荐使用的认证方式有:密码认证(PSK):设置无线终端接入无线网络时需要输入的密码.Po ...

  6. python搭建邮件服务器地址_python 配置邮件发送服务器发送邮件

    邮件发送脚本 #coding:utf-8 # #!/usr/bin/python import smtplib ,os from email.mime.text import MIMEText fro ...

  7. 电脑自建服务器tomcat,怎么配置搭建tomcat服务器

    tomcat是一种轻量级的web容器服务器,那么该怎么配置搭建tomcat服务器呢?下面是学习啦小编收集整理的怎么配置搭建tomcat服务器,希望对大家有帮助~~ 配置搭建tomcat服务器的方法 工 ...

  8. 如何配置系统数据库服务器地址,如何配置系统数据库服务器地址

    如何配置系统数据库服务器地址 内容精选 换一换 华为云提供两种连接方式通过SQL Server客户端连接实例:非SSL连接和SSL连接.其中,SSL连接实现了数据加密功能,具有更高的安全性.安装SQL ...

  9. linux服务器python环境配置+pycharm连接服务器操作

    普天同庆!!!从原来啥也不懂一直拖着想着等返校后问同学怎么操作,到现在迫于无奈需要训练只能自己配置,耗时半天终于搞明白了!!!(大神永远不懂小白的痛) 目录 1.linux服务器环境配置 1.1 安装 ...

最新文章

  1. 达摩院浙大上海人工智能实验室推出洛犀平台:大小模型端云协同进化
  2. Linux下的软raid实验一例
  3. 07_NoSQL数据库之Redis数据库:Redis的高级应用之事务处理、持久化操作、pub_sub、虚拟内存
  4. 【基础知识】 之 Binary Search Tree 二叉搜索树
  5. react dispatch_React测试的那些事(三) React Hook 测试实例
  6. windows下搭建iphone开发环境
  7. Oracle数据库日常管理之数据备份,恢复及迁移 (第五讲 )
  8. vscode 支持ansi_vscode terminal美化
  9. 修改图层的范围_PS教程连载第47课:PS图层操作案例星球
  10. 从下往上看--新皮层资料的读后感 第一部分:皮层细胞
  11. 映射java是什么_java – 映射,绑定和解析有什么区别?
  12. 2016中国APP分类排行榜参选入围产品公示
  13. Python习题——2018-03-28作业
  14. 健康指南:趴桌睡觉三大危害
  15. zynq获取程序运行时间
  16. C#等语言、反射机制实现简单 智能语音人机交互(2)-- 皓月
  17. 2022年最热门三款骨传导测评推荐:骨传导选购指南分享,骨传导耳机选哪款好?
  18. linux设置mac地址命令,[转载]Linux下修改MAC地址
  19. 电脑提示Word无法创建工作文件请检查临时环境变量怎么解决
  20. 【UE】直升机沿样条线移动

热门文章

  1. C语言中getchar()和putchar()函数
  2. 6163 - Myth Busters
  3. 安全漏洞漫谈 【http://luoluo.cnblogs.com/】
  4. 洛谷 #3959. 宝藏
  5. 手把手带你完成数据库课程设计(餐饮管理系统)
  6. Qt判断鼠标移动的同时鼠标左键被按下
  7. B1016_部分A+B
  8. CSS3动画 3D基础知识
  9. 使用jQuery+flot插件在网页中动态显示服务器CPU运行状态
  10. 超硬核!!!一篇文章掌握整个JVM,JVM超详细解析!!!