在企业生产实践中,对于经常进行DNS解析变动的测试环境,Bind9的维护是个不大不小的问题。运维开发通常需要提交相关请求之后,还需要SSH到解析服务器上去进行配置修改,就要开xshell然后登陆找配置项进行变更。为了节约脑力和时间,通过已经添加到导航面板的web gui书签跳转到域名管理平台再进行管理就要快捷一点点。

WebMin

为了方便管理DNS解析,我们可以使用Google SRE工程师Jamie Cameron开发的Webmin。这个工具是用perl语言编写的很强大的Linux主机管理面板,支持Linux主机环境的通用程序配置,包括Bind、Apache、MySQL等等。这位老哥还编写了管理虚拟化宿主机和类似cpanle的虚拟主机管理web平台。

安装

# 下载安装脚本
curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
# 添加官方repo地址
sh setup-repos.sh
# 执行安装并安装perl的功能模块
dnf makecache
dnf install -y perl-CPAN
dnf install -y perl-Convert-ASN1 perl-IO
dnf install -y make gcc automake
# 安装webmin
dnf install -y webmin
systemctl enable --now webmin
systemctl status wemin --no-pager
# 开启防火墙,webmin使用1000端口
firewall-cmd --permanent --add-port=10000/tcp
firewall-cmd --reload

开箱

  1. 登陆
    webmin

  2. 监控面板
    webmin

  3. web终端
    webmin

  4. 安装Bind9
    webmin

  5. 添加ssl证书

    webmin

Bind9

概念与术语

BIND(Berkeley Internet Name Domain)作为一款目前市面是最主流的开源DNS软件,占据了市面上DNS服务器软件的九成,目前由 互联网系统协会 (Internet Systems Consortium) 负责开发和维护。目前,最新的稳定版BIND已经更新到了 BIND 9 版本。

DNS ZONE

DNS Zone,DNS区域是构成DNS命名空间的一部分,可以对权威性域名服务器等DNS组件更加精细的控制。 域名空间是一个分层树,其中DNS的根域位于顶部,DNS区域始于该树中的一个域,并且可以扩展到下边的子域。

常见资源类型

  1. A :Address地址, IPv4
  2. AAAA:Address地址 IPv6
  3. NS :Name Server域名服务器,用于确定哪些服务器为一个局域网传递DNS信息以及确定域名由哪个服务器进行解析
  4. SOA:Start of Authority 起始授权机构, 被标记成在众多NS记录中哪一台是主服务器
  5. MX:Mail Exchanger 邮件交换
  6. CNAME:Canonical Name规范名
  7. PTR:Pointer 指针,即反向DNS系统,即查询IP地址的PTR记录给出该IP指向的域名
  8. TXT:Text,网络名称系统的记录,可讲文字信息提供给网络意外的来源
  9. SRV:Service 记录,域名中用于指定服务器并提供服务的位置
  10. CNAME:域名的别名
  11. SRV (Service): 被用来记录服务器提供什么样的服务。

创建

bind9

生效

bind9

测试

# 下载DNS压力测试工具
wget https://ftp.isc.org/isc/bind9/9.12.4/bind-9.12.4.tar.gz
tar zaxf bind-9.12.4.tar.gz
cd bind-9.12.4/contrib/queryperf/
./configure
make
chmod +x queryperf
cp queryperf /usr/local/bin/
# 使用帮助
[root@infra ~]# queryperf -h

DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $


Usage: queryperf [-d datafile] [-s server_addr] [-p port] [-q num_queries]
[-b bufsize] [-t timeout] [-n] [-l limit] [-f family] [-1]
[-i interval] [-r arraysize] [-u unit] [-H histfile]
[-T qps] [-e] [-D] [-R] [-c] [-v] [-h]
-d specifies the input data file (default: stdin)
-s sets the server to query (default: 127.0.0.1)
-p sets the port on which to query the server (default: 53)
-q specifies the maximum number of queries outstanding (default: 20)
-t specifies the timeout for query completion in seconds (default: 5)
-n causes configuration changes to be ignored
-l specifies how a limit for how long to run tests in seconds (no default)
-1 run through input only once (default: multiple iff limit given)
-b set input/output buffer size in kilobytes (default: 32 k)
-i specifies interval of intermediate outputs in seconds (default: 0=none)
-f specify address family of DNS transport, inet or inet6 (default: any)
-r set RTT statistics array size (default: 50000)
-u set RTT statistics time unit in usec (default: 100)
-H specifies RTT histogram data file (default: none)
-T specify the target qps (default: 0=unspecified)
-e enable EDNS 0
-D set the DNSSEC OK bit (implies EDNS)
-R disable recursion
-c print the number of packets with each rcode
-v verbose: report the RCODE of each response on stdout
-h print this usage
# 创建测试文件,生成5000个域名解析请求
[root@infra ~]# cat touchdnstest.sh
#!/bin/sh
var=1
while [ $var -le 5000 ]
do
cat>>test<<EOF
git.contoso.com A
EOF

var=$(($var + 1 ))

done
exit 0
# 调用test文件,查询文件中的解析请求,DNS服务器地址为本地,端口为53
# 设定每秒查询10000次
[root@infra ~]# queryperf -d test -s 127.0.0.1 -p 53 -T 10000

DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $

[Status] Processing input data
[Status] Sending queries (beginning with 127.0.0.1)
[Status] Testing complete

Statistics:

Parse input file: once
Ended due to: reaching end of file

Queries sent: 5000 queries
Queries completed: 5000 queries
Queries lost: 0 queries
Queries delayed(?): 0 queries

RTT max: 0.001521 sec
RTT min: 0.000034 sec
RTT average: 0.000456 sec
RTT std deviation: 0.000242 sec
RTT out of range: 0 queries

Percentage completed: 100.00%
Percentage lost: 0.00%

Started at: Tue Oct 31 09:41:38 2023
Finished at: Tue Oct 31 09:41:39 2023
Ran for: 0.500451 seconds

Queries per second: 9990.988129 qps
Total QPS/target: 9991.028057/10000 qps

参考

最详细、最认真的从零开始的 BIND 9