简言
当我们分析DNS 服务器日志时,希望了解哪些用户在使用DNS 服务器,同时也希望对DNS 查询做一个统计。一般情况下,可以使用命令“tcpdump –i eth0 port 53”来查看DNS查询包,当然也可以把输出重定向到文件,然后使用rndc stats(bind9)来获取。但这种方法对于初学者而言操作复杂,也不直观。下面介绍的这款工具dnstop,使用起来就非常方便。
dnstop是一种非常优秀的开源软件,用户可以到网站http://dns.measurement-factory.com/tools/dnstop/src/上进行下载使用
安装
1.安装依赖
yum -y install ncurses-devel libpcap-devel
2.编译安装dnstop
wget 'http://dns.measurement-factory.com/tools/dnstop/src/dnstop-20140915.tar.gz'
tar -zxvf dnstop-20140915.tar.gz
cd dnstop-20140915
./configure
make && make install
3.使用方式
- eth0为网卡名称
dnstop -4 -Q -R eth0
4.参数说明
dnstop -help
[root@localhost ~]# dnstop -help
dnstop: invalid option -- 'h'
usage: dnstop [opts] netdevice|savefile
-4 Count IPv4 packets
-6 Count IPv6 packets
-Q Count queries
-R Count responses
-a Anonymize IP Addrs
-b expr BPF program code
-i addr Ignore this source IP address
-n name Count only messages in this domain
-p Don't put interface in promiscuous mode
-P Print "progress" messages in non-interactive mode
-r Redraw interval, in seconds
-l N Enable domain stats up to N components
-X Don't tabulate the "source + query name" stats
-f filter-name
Available filters:
unknown-tlds
A-for-A
rfc1918-ptr
refused
qtype-any
5.交互参数说明
在dnstop运行时,可以输入如下按键,获取特定内容
S:显示源地址表
D:显示目标地址表
T:显示所见查询类型的细分
R:显示所看到的响应代码的细分
O:显示所看到的操作码的细分
1:显示第一级查询名称
2:显示第二级查询名称
3:显示了第3级查询名称
4:显示第4级查询名称
Ctr+R:重新纪录
Ctr+X:退出