五、bind各种辅助工具

一、bind-utils软件包 该软件包,包含一下工具

代码语言:javascript
复制
/usr/bin/dig
/usr/bin/host
/usr/bin/nslookup
/usr/bin/nsupdate

nsupdate是用来更新bind的区域文件的比节不细说

主要说两个dig和host(主要用于域名解析查询)

代码语言:javascript
复制
dig:
    dig [-t type] name [@SERVER] [query options]
    dig只用于测试dns系统,不会查询hosts文件进行解析
查询选项:
    +[no]trace:跟踪解析过程 : dig +trace magedu.com
    +[no]recurse:进行递归解析
测试反向解析:
    dig -x IP = dig –t ptr reverseip.in-addr.arpa
模拟区域传送:
    dig -t axfr ZONE_NAME @SERVER   查询server的真个区域记录,是同tcp53端口
    dig -t axfr magedu.com @10.10.10.11
    dig –t axfr 100.1.10.in-addr.arpa @172.16.1.1
    dig -t NS . @114.114.114.114    查询114这个dns下的权威dns服务器记录
    dig -t NS . @a.root-servers.ne

host(和dig功能类似,显示更简洁):

host [-t type] name [SERVER]
host –t NS magedu.com 172.16.0.1
host –t soa magedu.com
host –t mx magedu.com
host –t axfr magedu.com
host 1.2.3.4</code></pre></div></div><p>二、rndc命令 

rndc实际上是通过资深的 953tcp端口连接本机寄信管理的。

代码语言:javascript
复制
rndc:
格式:rndc COMMAND
COMMAND:
reload: 重载主配置文件和区域解析库文件
reload zonename: 重载区域解析库文件
retransfer zonename: 手动启动区域传送,而不管序列号是否增加
notify zonename: 重新对区域传送发通知
reconfig: 重载主配置文件
querylog: 开启或关闭查询日志文件/var/log/message
trace: 递增debug一个级别
trace LEVEL: 指定使用的级别
notrace:将调试级别设置为 0
flush:清空DNS服务器的所有缓存记录

三、bind源码包下contrib目录下的各种工具(工具需要编译)
我们以源码包bind-9.11.2-P1.tar为例,我只写一种常用的性能测试工具

代码语言:javascript
复制
[root@localhost ~]# tar -xf bind-9.11.2-P1.tar.gz
[root@localhost ~]# cd bind-9.11.2-P1/contrib
[root@localhost ~]# ls
dane idn perftcpdns README zkt-1.1.3
dlz kasp query-loc-0.4.0 scripts
dnsperf-2.1.0.0-1 nslint-3.0a2 queryperf sdb
README 这个文件中有每一个工具的简介,之后我们会介绍几个常用的工具

queryperf

代码语言:javascript
复制
queryperf是用来为DNS做压力测试的工具,要使用它,我们需要先编译

[root@localhost contrib]# cd queryperf/
[root@localhost queryperf]# ./configure
configure
..

[root@localhost queryperf]# make
gcc -DHAVE_CONFIG_H -c queryperf.c
gcc -DHAVE_CONFIG_H queryperf.o -lnsl -lresolv -lm -o queryperf
在当前目录会生成一个名叫“queryperf”的可执行文件,我们将这个文件拷贝到/usr/bin/下
[root@localhost queryperf]#cp -a queryperf /usr/bin/ #注意权限,使用-a选项
查看该命令的用法
[root@localhost ~]# 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

我们常用的一般就两个 -s指定dns服务器,-d指定文件

代码语言:javascript
复制
例:
vim ./address
www.baidu.com A

使用vim的批量复制功能50000p粘贴5w条副本(如果不知道怎么使用可以在在word或者txt文本中粘贴)

进行压力测试

代码语言:javascript
复制
[root@localhost ~]# queryperf -s 223.6.6.6 -d address
Statistics:
Parse input file: once
Ended due to: reaching end of file
Queries sent: 50001 queries
Queries completed: 50001 queries
Queries lost: 0 queries
Queries delayed(?): 0 queries
RTT max: 0.092429 sec
RTT min: 0.041393 sec
RTT average: 0.047024 sec
RTT std deviation: 0.004141 sec
RTT out of range: 0 queries
Percentage completed: 100.00%
Percentage lost: 0.00%
Started at: Sun Jan 21 12:52:26 2018
Finished at: Sun Jan 21 12:54:42 2018
Ran for: 136.613603 seconds
Queries per second: 366.003084 qps
5w个请求136秒完成丢失0个,这个是阿里的dns,很好用的一个压力测试工具,在搭建私有的dns时可以用于测试