[关闭]
@cdmonkey 2021-10-18T10:01:14.000000Z 字数 3638 阅读 1546

unbound

网络服务


Official Website: https://nlnetlabs.nl/projects/unbound/download

https://lisz.io/tech/unbound-dns.html
http://blog.51cto.com/11246696/1902705
http://3g.163.com/dy/article/DCCMUSBF0511RVML.html
https://www.linuxprobe.com/use-unbound-rhel7-setup-dns.html
https://blog.phoenixlzx.com/2016/04/27/better-dns-with-unbound
https://www.sooele.com/index.php/2018/03/08/1567

https://loga.us/2014/08/03/unbound-caching-and-nsd-local-authoritative-master-slave-dns-server-part-1
https://calomel.org/unbound_dns.html
https://www.holoem.com/?p=768

官方文档:

https://nlnetlabs.nl/documentation/unbound/

安装依赖包:

  1. yum install gcc libevent* expat*
  2. yum install openssl openssl-devel
  1. [root@ldap01 unbound-1.8.1]# ./configure --prefix=/usr/local/unbound \
  2. --with-pthreads --with-libevent --with-ssl
  3. make && make install
  1. ln -s /usr/local/unbound/sbin/unbound /usr/local/bin/unbound
  2. ln -s /usr/local/unbound/sbin/unbound-anchor /usr/local/bin/unbound-anchor
  3. ln -s /usr/local/unbound/sbin/unbound-checkconf /usr/local/bin/unbound-checkconf
  4. ln -s /usr/local/unbound/sbin/unbound-control /usr/local/bin/unbound-control
  5. ln -s /usr/local/unbound/sbin/unbound-control-setup /usr/local/bin/unbound-control-setup
  6. ln -s /usr/local/unbound/sbin/unbound-host /usr/local/bin/unbound-host

创建用户:

  1. groupadd unbound
  2. useradd -M -g unbound -s /sbin/nologin unbound

启动服务:

  1. /usr/local/unbound/sbin/unbound -c /usr/local/unbound/etc/unbound/unbound.conf

查看状态:

  1. [root@PBSNEWDNSNTP01 ~]# unbound-control status
  2. version: 1.8.1
  3. verbosity: 1
  4. threads: 8
  5. modules: 2 [ validator iterator ]
  6. uptime: 14307466 seconds
  7. options: reuseport control
  8. unbound (pid 76444) is running...
  1. [root@PBSNEWDNSNTP01 ~]# unbound-control list_forwards
  2. . IN forward 223.5.5.5 223.6.6.6

TTL & Cache

  1. cache-min-ttl: 0 # 生存时间TTL值下限,单位秒,默认值0。若超过一个小时很容易因陈旧数据而出现问题。
  2. cache-max-ttl: 86400
  3. cache-max-negative-ttl: 3600
  4. infra-host-ttl: 900
  5. infra-cache-min-rtt: 50
  6. infra-cache-slabs: 4
  7. infra-cache-numhosts: 10000

管理

https://l-w-i.net/t/unbound/control_001.txt

使用 SSL 用于连接服务器而不管它是本地还是远程服务器,因而首先需要于服务器端创建 SSL 证书。连接至远程服务器时,于远程端创建证书并且于本地复制。

为此,请使用 unbound-control-setup 这个工具。

创建密钥

  1. [root@PBSNEWDNSNTP04 ~]# unbound-control-setup
  2. ...
  3. Getting CA Private Key
  4. Setup success. Certificates created. Enable in unbound.conf file to use
  5. # 设置成功。证书已创建。可于 unbound.conf 文件中启用以使用。

完成上述操作后,就于 /usr/local/unbound/etc/unbound/ 下创建了四种类型证书:

  1. [root@PBSNEWDNSNTP04 ~]# ls /usr/local/unbound/etc/unbound/|grep unbound_
  2. unbound_control.key # 客户端的密钥 key
  3. unbound_control.pem # 客户端的公钥证书 pem
  4. unbound_server.key # 服务器的密钥 key
  5. unbound_server.pem # 服务器的公钥证书 pem

配置

  1. remote-control:
  2. # 这个区间为控制设置。配置如下内容可以控制 unbound 服务。
  3. # 使用 unbound-control 命令对能够该服务执行开启、关闭、重启等操作。
  4. control-enable: yes
  5. control-interface: 127.0.0.1
  6. control-port: 8953
  7. server-key-file: "/usr/local/unbound/etc/unbound/unbound_server.key"
  8. server-cert-file: "/usr/local/unbound/etc/unbound/unbound_server.pem"
  9. control-key-file: "/usr/local/unbound/etc/unbound/unbound_control.key"
  10. control-cert-file: "/usr/local/unbound/etc/unbound/unbound_control.pem"

注意:
若是服务器上禁用了 IPv6,则需要于配置文件中修改相关配置:

  1. do-ip6: no

另外,日志目录需要自行创建。

配置文件检查

https://nlnetlabs.nl/documentation/unbound/unbound-checkconf

  1. [root@newdns01 ~]# unbound-checkconf
  2. unbound-checkconf: no errors in /usr/local/unbound/etc/unbound/unbound.conf
  3. [root@newdns01 ~]# unbound-checkconf /usr/local/unbound/etc/unbound/extra/vbillbank.conf
  4. unbound-checkconf: no errors in /usr/local/unbound/etc/unbound/extra/vbillbank.conf

重新加载配置文件

  1. unbound-control reload

反向解析

http://www.361way.com/rh254-unbound/4672.html


Queryperf

  1. [root@PBSDNSNTP02 ~]# cd tools/bind-9.12.2-P2
  2. [root@PBSDNSNTP02 bind-9.12.2-P2]# cd contrib/queryperf/
  3. ./configure
  4. make

测试指令:

  1. ./queryperf -d ./yuming.txt -s 10.1.30.231

排错

启动报错

  1. unbound[111537:0] error: could not read root hints /etc/unbound/named.cache: No such file or directory
  2. unbound[111537:0] error: Could not set root or stub hints

解决:

  1. cd /usr/local/unbound/etc/unbound/
  2. wget https://www.internic.net/domain/named.cache
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注