BIND(三)—— DNS工具和BIND日志.md

dns压测

queryperf在BIND源码包种自带,但是RPM包安装中并没有

1、安装queryperf

//安装依赖 
yum groupinstall "Development tools" "Server Platform Development" -y

tar xf bind-9.10.0-P1.tar.gz
cd bind-9.10.0-P1/contrib/queryperf/
./configure
make
cp queryperf /bin/

2、基本使用

queryperf --help //查询帮助 
# queryperf -d dns.txt -s 192.168.122.131

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 192.168.122.131)
[Timeout] Query timed out: msg id 1
[Timeout] Query timed out: msg id 2
[Status] Testing complete

Statistics:

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

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

RTT max: -1.000000 sec
RTT min: -1.000000 sec
RTT average: 0.000000 sec
RTT std deviation: 0.000000 sec
RTT out of range: 0 queries

Percentage completed: 100.00%
Percentage lost: 0.00%

Started at: Mon Jun 2 21:42:25 2014
Finished at: Mon Jun 2 21:42:30 2014
Ran for: 5.000052 seconds

Queries per second: 0.399996 qps

dnstop

1、安装dnstop

yum install libpcap-devel 
wget http://dns.measurement-factory.com/tools/dnstop/src/dnstop-20121017.tar.gz
tar xf dnstop-20121017.tar.gz
cd dnstop-20121017
./configure
make
make install

BIND日志

先来大致看一段日志格式 
logging {
channel b_log {
file "../log/bind.log" versions 30 size 1m;
print-time yes;
print-category yes;
print-severity yes;
severity info;
};

channel b_debug {
file "../log/debug.log" versions 2 size 1m;
print-time yes;
print-category yes;
print-severity yes;
severity dynamic;
};

channel b_query {
file "../log/query.log" versions 2 size 1m;
print-time yes;
severity info;
};

category default { b_log; b_debug; };
category config { b_log; b_debug; };
category queries { b_query; };
};

语法

logging { 
channel string {
file log_file [versions number|unlimited] [size sizespec]; | syslog optional_facility; |null; |stderr;;
severity ;;
print-time < yes|no >;;
print-severity boolean;;
print-category boolean;; };

category string { string; ... };
};

1、channel

  • 在日志配置中主要有channel和category两种类别
  • channel用于指定日志发送目标,其中channel 用下用于指定channel名称,将日志输入到中指定的文件中,这里所指定的路径是一个相对路径,实际路径需要权限全局配置文件options块中direcotry决定,不管指定什么路径named用户必须有写权限
  • versions指定允许同时存在多少个版本的日志文件,比如指定version 3,就会保存logfile.log、logfile.log0、logfile.log1 和logfile.log2,然后建立一个新的log_file.log进行写入的时候,就会删除最开始的logfile.log2,
  • unlimited表示无限制写入,默认就是unlimited。
  • size指定文件大小的上限,如果只指定了size而没有指定versions,当文件达到指定的上限时,BIND将停止写入该日志文件。
  • syslog optional_facility:将日志输入到syslog,其中optional_facility是syslog的设备名。
  • severity:指定日志级别
  • log level:
- critical(比error量多严重的错误信息) 
- error(一些重大的错误信息,比如配置文件的某些值造成该服务无法启动的信息说明,通常由error的错误通知)
- warning(可能有错误,但是还不至于影响到服务远行的信息)
- notice(比info更需要被注意的一些信息)
- info(一些基本的信息说明)
- debug(当需要进行错误检查或忽略某些服务的信息时使用)
- dynamic(一个特殊的值,它匹配服务器当前的调试级别定义了某个严重性级别后,系统会记录包括该级别以及比该级别更严重的级别的所有消息。比如定义级别为error,则会记录critical和error两个级别的信息)
  • print-time: 指定在日志中是否需要写入时间
  • print-severity:指定在日志中是否需要写入消息级别
  • print-category:指定在日志中是否需要写入日志类别

2、category

# bind内置15中category,是用来定义日志内容 
1、client:处理客户端请求。
2、config:配置文件分析和处理。
3、database:同BIND内部数据库相关的消息,用来存储区数据和缓存记录。
4、default:匹配所有未明确指定通道的类别。
5、dnssec:处理DNSSEC签名的响应。
6、general:包括所有未明确分类的BIND消息。
7、lame-servers:发现错误授权。
8、network:网络操作。
9、notify:区更新通知消息。
10、queries:查询日志。
11、resolver:名字解析,包括对来自解析器的递归查询信息。
12、security:批准/非批准的请求。
13、update:动态更新事件。
14、xfer-in:从远程名字服务器到本地名字服务器的区域传送。
15、xfer-out:从本地名字服务器到远程名字服务器的区域传送。

# 特别注意
一个category产生的日志只能发往多个channel,而一个channel只能为一个category记录日志

3、实例

logging { 
channel b_log {
file "../log/bind.log" versions 30 size 1m;
print-time yes;
print-category yes;
print-severity yes;
severity info;
};

channel b_debug {
file "../log/debug.log" versions 2 size 1m;
print-time yes;
print-category yes;
print-severity yes;
severity dynamic;
};

channel b_query {
file "../log/query.log" versions 2 size 1m;
print-time yes;
severity info;
};

category default { b_log; b_debug; };
category config { b_log; b_debug; };
category queries { b_query; }; };
- 此时回头看看上面的实例 含义为定义了三个channel,b_log,b_query,b_debug
- 分别写入日志bind.log, query.log, debug.log;
- 将default信息记录到bind.log和debug.log中;
- 将config信息记录到bind.log和debug.log中;
- 将query信息记录到query.log中

你可能感兴趣的:(log,bind,queryperf,dnstop)