簡言
當我們分析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:退出