欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
Dns配置高级篇
第36行: | 第36行: | ||
2.logging 通过该选项,我们可以生成我们想要的日志。通过日志,我们可以更好地维护dns服务器。 | 2.logging 通过该选项,我们可以生成我们想要的日志。通过日志,我们可以更好地维护dns服务器。 | ||
− | <font color="red"> | + | <font color="red"> |
Logging { | Logging { | ||
Channel syslog_info { | Channel syslog_info { | ||
第48行: | 第48行: | ||
}; | }; | ||
}; | }; | ||
− | </font> | + | </font> |
上例中我们建立了一个安全级别为notice的日志,dns的报错信息都会存放在"/var/log/bindall.log"日志文件了,分析该文件,我们就能轻松找出dns工作不正常的原因了。 | 上例中我们建立了一个安全级别为notice的日志,dns的报错信息都会存放在"/var/log/bindall.log"日志文件了,分析该文件,我们就能轻松找出dns工作不正常的原因了。 | ||
Logging里面的安全级别很多,大家可以根据自己需要来制定一个或多个logging。下面是logging的语法: | Logging里面的安全级别很多,大家可以根据自己需要来制定一个或多个logging。下面是logging的语法: | ||
− | <font color="red"> | + | |
+ | <font color="red"> | ||
logging { | logging { | ||
[ channel channel_name { | [ channel channel_name { | ||
− | |||
( file path_name | ( file path_name | ||
− | |||
[ versions ( number | unlimited ) ] | [ versions ( number | unlimited ) ] | ||
− | |||
[ size size_spec ] | [ size size_spec ] | ||
− | |||
| syslog ( kern | user | mail | daemon | auth | syslog | lpr | | | syslog ( kern | user | mail | daemon | auth | syslog | lpr | | ||
− | |||
news | uucp | cron | authpriv | ftp | | news | uucp | cron | authpriv | ftp | | ||
− | |||
local0 | local1 | local2 | local3 | | local0 | local1 | local2 | local3 | | ||
− | |||
local4 | local5 | local6 | local7 ) | local4 | local5 | local6 | local7 ) | ||
− | |||
| null ); | | null ); | ||
− | |||
− | |||
− | |||
[ severity ( critical | error | warning | notice | | [ severity ( critical | error | warning | notice | | ||
− | |||
info | debug [ level ] | dynamic ); ] | info | debug [ level ] | dynamic ); ] | ||
− | |||
[ print-category yes_or_no; ] | [ print-category yes_or_no; ] | ||
− | |||
[ print-severity yes_or_no; ] | [ print-severity yes_or_no; ] | ||
− | |||
[ print-time yes_or_no; ] | [ print-time yes_or_no; ] | ||
− | |||
}; ] | }; ] | ||
− | |||
− | |||
− | |||
[ category category_name { | [ category category_name { | ||
− | |||
channel_name; [ channel_name; ... ] | channel_name; [ channel_name; ... ] | ||
− | |||
}; ] | }; ] | ||
− | |||
... | ... | ||
− | + | }; | |
− | }; | + | </font> |
− | + | ||
− | + | ||
− | + | ||
3. 这里是我们named.conf样本,希望能对你有所帮助。 | 3. 这里是我们named.conf样本,希望能对你有所帮助。 | ||
第113行: | 第89行: | ||
我们named.conf的样本 | 我们named.conf的样本 | ||
− | acl hatenets { | + | acl hatenets { |
− | + | ||
1.0.0.0/8; | 1.0.0.0/8; | ||
− | |||
2.0.0.0/8; | 2.0.0.0/8; | ||
− | + | };<br> | |
− | }; | + | options { |
− | + | ||
− | + | ||
− | + | ||
− | options { | + | |
− | + | ||
files 10000; | files 10000; | ||
− | + | # boot file for name server | |
− | # boot file for name server | + | # |
− | + | ||
− | # | + | |
− | + | ||
directory "/var/named"; | directory "/var/named"; | ||
− | |||
version "I am cpss"; | version "I am cpss"; | ||
− | |||
notify no; | notify no; | ||
− | |||
datasize 300m; | datasize 300m; | ||
− | |||
allow-transfer {192.168.1.1; | allow-transfer {192.168.1.1; | ||
− | |||
192.168.1.4; | 192.168.1.4; | ||
− | |||
}; | }; | ||
− | |||
− | |||
− | |||
blackhole { hatenets; }; | blackhole { hatenets; }; | ||
− | |||
interface-interval 0; | interface-interval 0; | ||
− | + | cleaning-interval 120; | |
− | cleaning-interval 120; | + | |
− | + | ||
listen-on {192.168.1.2; | listen-on {192.168.1.2; | ||
− | |||
}; | }; | ||
− | + | statistics-interval 60; <br> | |
− | statistics-interval 60; | + | logging { |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | logging { | + | |
− | + | ||
channel syslog_query { | channel syslog_query { | ||
− | |||
file "/var/log/bindquery.log" ; | file "/var/log/bindquery.log" ; | ||
− | + | severity notice; | |
− | severity notice; | + | }; |
− | + | channel syslog_info { | |
− | }; | + | |
− | + | ||
− | + | ||
− | + | ||
− | channel syslog_info { | + | |
− | + | ||
file "/var/log/bindall.log" versions 20 size 2m; | file "/var/log/bindall.log" versions 20 size 2m; | ||
− | |||
print-category yes; | print-category yes; | ||
− | |||
print-time yes; | print-time yes; | ||
− | |||
print-severity yes; | print-severity yes; | ||
− | |||
severity notice; | severity notice; | ||
− | + | }; | |
− | }; | + | |
− | + | ||
− | + | ||
− | + | ||
channel syslog_manitenance { | channel syslog_manitenance { | ||
− | |||
file "/var/log/bindmaint.log" versions 10 size 2m; | file "/var/log/bindmaint.log" versions 10 size 2m; | ||
− | |||
severity notice; | severity notice; | ||
− | |||
}; | }; | ||
− | |||
− | |||
− | |||
channel syslog_secu { | channel syslog_secu { | ||
− | |||
syslog local6; | syslog local6; | ||
− | |||
severity info; | severity info; | ||
− | |||
}; | }; | ||
− | |||
− | |||
− | |||
channel syslog_xfer { | channel syslog_xfer { | ||
− | |||
file "/var/log/bindxfer.log" versions 20 size 2m; | file "/var/log/bindxfer.log" versions 20 size 2m; | ||
− | |||
print-category yes; | print-category yes; | ||
− | |||
print-time yes; | print-time yes; | ||
− | |||
print-severity yes; | print-severity yes; | ||
− | |||
severity notice; | severity notice; | ||
− | |||
}; | }; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
channel syslog_os { | channel syslog_os { | ||
− | |||
syslog local3; | syslog local3; | ||
− | |||
severity info; | severity info; | ||
− | |||
}; | }; | ||
− | |||
− | |||
− | |||
channel syslog_panic { | channel syslog_panic { | ||
− | |||
syslog local4; | syslog local4; | ||
− | |||
severity info; | severity info; | ||
− | |||
}; | }; | ||
− | |||
− | |||
− | |||
channel syslog_stat { | channel syslog_stat { | ||
− | |||
syslog local5; | syslog local5; | ||
− | |||
severity info; | severity info; | ||
− | |||
}; | }; | ||
− | |||
− | |||
− | |||
channel syslog_config { | channel syslog_config { | ||
− | |||
file "/var/log/bind_config.log" versions 20 size 2m; | file "/var/log/bind_config.log" versions 20 size 2m; | ||
− | |||
print-category yes; | print-category yes; | ||
− | |||
print-time yes; | print-time yes; | ||
− | |||
print-severity yes; | print-severity yes; | ||
− | |||
severity info; | severity info; | ||
− | |||
}; | }; | ||
− | + | category "xfer-in" { | |
− | category "xfer-in" { | + | |
− | + | ||
syslog_xfer; | syslog_xfer; | ||
− | |||
}; | }; | ||
− | + | category default { | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | category default { | + | |
− | + | ||
syslog_info; | syslog_info; | ||
− | |||
}; | }; | ||
− | + | category security { | |
− | + | ||
− | + | ||
− | category security { | + | |
− | + | ||
syslog_secu; | syslog_secu; | ||
− | |||
}; | }; | ||
− | + | category os { | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | category os { | + | |
− | + | ||
syslog_os; | syslog_os; | ||
− | |||
− | |||
− | |||
}; | }; | ||
− | + | category panic { | |
− | + | ||
− | + | ||
− | category panic { | + | |
− | + | ||
syslog_panic; | syslog_panic; | ||
− | |||
}; | }; | ||
− | + | category statistics { | |
− | + | ||
− | + | ||
− | category statistics { | + | |
− | + | ||
syslog_stat; | syslog_stat; | ||
− | |||
}; | }; | ||
− | + | category config { | |
− | + | ||
− | + | ||
− | category config { | + | |
− | + | ||
syslog_config; | syslog_config; | ||
− | |||
}; | }; | ||
− | + | category maintenance { | |
− | + | ||
− | + | ||
− | category maintenance { | + | |
− | + | ||
syslog_manitenance; | syslog_manitenance; | ||
− | |||
}; | }; | ||
− | + | category lame-servers {null; }; | |
− | + | category cname {null; }; | |
− | + | }; | |
− | + | # | |
− | + | # type domain source host/file | |
− | category lame-servers {null; }; | + | # |
− | + | zone "." { | |
− | + | ||
− | + | ||
− | category cname {null; }; | + | |
− | + | ||
− | + | ||
− | + | ||
− | }; | + | |
− | + | ||
− | + | ||
− | + | ||
− | # | + | |
− | + | ||
− | # type domain source host/file | + | |
− | + | ||
− | # | + | |
− | + | ||
− | zone "." { | + | |
− | + | ||
type hint; | type hint; | ||
− | |||
file "/var/named/named.ca"; | file "/var/named/named.ca"; | ||
− | + | }; | |
− | }; | + | zone "0.0.127.IN-ADDR.ARPA" { |
− | + | ||
− | + | ||
− | + | ||
− | zone "0.0.127.IN-ADDR.ARPA" { | + | |
− | + | ||
type master; | type master; | ||
− | |||
file "local.rev"; | file "local.rev"; | ||
− | + | }; | |
− | }; | + |
2008年4月28日 (一) 04:09的最后版本
Dns配置高级篇
这里假设你已经独立或参考我的《架设dns攻略》将dns服务器成功架设起来,并且dns已经能够正常运行了。
现在我们dns开始工作了,是不是我们的工作已经OK了呢?不,不,不,named.conf文件还有很多东西需要我们配置呢。
DNS的配置文件named.conf是有非常多的可选项的,这里只是介绍一点常用的配置。如果你觉得还想继续研究下去,那也不需要在网上到处找资料的,直接用“man named.conf”就可以得到一个非常非常详细的说明。
这里首先感谢我的同事yiming先生对服务器安全性的不懈研究,否则我们也不会经常安装、配置最新版本的DNS服务器了。而且,这个named.conf是他配置的。好了,言归正传,Follow me,我们继续。
1.Options 我们通过options可以定制一个性能更优、安全性更高的dns服务器。
Version "I am cpss"
别人想探测我们dns版本,然后根据该版本的漏洞来攻击我们。休想!配置了这条命令后,别人再探测的版本后就是“I am cpss”了,呵呵。
Allow-transfer {192.168.1.1;192.168.1.4;};
如果没有配置这一条命令,任何人都可以通过nslookup工具来得到你域里面的zone文件,也就是说他得到了你的主机列表,然后再分析,再……。当然,slave dns需要你允许它能够传送,否则它就得不到master dns上的zone文件,也就没办法工作了。这里假设192.168.1.1和192.168.1.4是该dns服务器的slave服务器,在master服务器上配置了如上命令。
Listen-on{192.168.1.2;};
增加上这条命令,启动dns时就不会监听所有网络接口的53端口了,只监听指定网络接口的53端口。
Blackhole {hatenets;};
我们不想让某些网段使用我们的dns服务器,就用这条命令吧。不过还需要配置一个acl来定义匹配的网段,如下所示:
acl hatenets { 1.0.0.0/8; 2.0.0.0/8; };
这两个网段的地址是无法使用我们的dns了。
2.logging 通过该选项,我们可以生成我们想要的日志。通过日志,我们可以更好地维护dns服务器。
Logging { Channel syslog_info { File "/var/log/bindall.log" versions 20 size 2m; Print-category yes; Print-time yes; Severity notice; }; category default { syslog_info; }; };
上例中我们建立了一个安全级别为notice的日志,dns的报错信息都会存放在"/var/log/bindall.log"日志文件了,分析该文件,我们就能轻松找出dns工作不正常的原因了。
Logging里面的安全级别很多,大家可以根据自己需要来制定一个或多个logging。下面是logging的语法:
logging { [ channel channel_name { ( file path_name [ versions ( number | unlimited ) ] [ size size_spec ] | syslog ( kern | user | mail | daemon | auth | syslog | lpr | news | uucp | cron | authpriv | ftp | local0 | local1 | local2 | local3 | local4 | local5 | local6 | local7 ) | null ); [ severity ( critical | error | warning | notice | info | debug [ level ] | dynamic ); ] [ print-category yes_or_no; ] [ print-severity yes_or_no; ] [ print-time yes_or_no; ] }; ] [ category category_name { channel_name; [ channel_name; ... ] }; ] ... };
3. 这里是我们named.conf样本,希望能对你有所帮助。
4.最新版本(2002年11月5日)的named.ca文件。
cpss 回复于:2003-02-16 19:45:07
我们named.conf的样本
acl hatenets { 1.0.0.0/8; 2.0.0.0/8; };
options { files 10000; # boot file for name server # directory "/var/named"; version "I am cpss"; notify no; datasize 300m; allow-transfer {192.168.1.1; 192.168.1.4; }; blackhole { hatenets; }; interface-interval 0; cleaning-interval 120; listen-on {192.168.1.2; }; statistics-interval 60;
logging { channel syslog_query { file "/var/log/bindquery.log" ; severity notice; }; channel syslog_info { file "/var/log/bindall.log" versions 20 size 2m; print-category yes; print-time yes; print-severity yes; severity notice; }; channel syslog_manitenance { file "/var/log/bindmaint.log" versions 10 size 2m; severity notice; }; channel syslog_secu { syslog local6; severity info; }; channel syslog_xfer { file "/var/log/bindxfer.log" versions 20 size 2m; print-category yes; print-time yes; print-severity yes; severity notice; }; channel syslog_os { syslog local3; severity info; }; channel syslog_panic { syslog local4; severity info; }; channel syslog_stat { syslog local5; severity info; }; channel syslog_config { file "/var/log/bind_config.log" versions 20 size 2m; print-category yes; print-time yes; print-severity yes; severity info; }; category "xfer-in" { syslog_xfer; }; category default { syslog_info; }; category security { syslog_secu; }; category os { syslog_os; }; category panic { syslog_panic; }; category statistics { syslog_stat; }; category config { syslog_config; }; category maintenance { syslog_manitenance; }; category lame-servers {null; }; category cname {null; }; }; # # type domain source host/file # zone "." { type hint; file "/var/named/named.ca"; }; zone "0.0.127.IN-ADDR.ARPA" { type master; file "local.rev"; };