Linux下源代码编译bind9.6安装和配置DNS服务器
http://www.isc.org/products/BIND/ 下载bind最新 bind-9.6.1rc1.tar.gz notify yes; view "test" { 或: $TTL 86400 @ IN SOA @ root.localhost ( 官方推荐:刷新:24小时 重试 2小时 期满30天 默认ttl 4天 @ IN A 127.0.0.1 使用rndc-confgen > rndc.conf生成key文件 然后通过tail -n10 rndc.conf | head -n9 | sed -e s/#\ //g >> named.conf将key文件写入name.conf key "rndc-key" { notify — Controls whether named notifies the slave servers when a zone is updated. It accepts the following options: yes — Notifies slave servers. no — Does not notify slave servers. explicit — Only notifies slave servers specified in an also-notify list within a zone statement. allow-update — Specifies the hosts that are allowed to dynamically update information in their zone. The default is to deny all dynamic update requests. acl.conf: acl "CNC" { xx.xx.xx.xx/xx; } 1.递归查询: http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-guide/s1-bind-namedconf.html
#./configure --prefix=/usr/local/named --enable-threads #--enable-threads开启多线程处理能力
#make
#make install
#cd /var/named
这是bsd的一个简单配置文件:
options {
directory "/var/named";#我去哪找解析文件
pid-file "/var/run/named/pid";进程文件放这吧
dump-file "/var/dump/named_dump.db";
statistics-file "/var/stats/named.stats";
listen-on { 192.168.0.83; };监听
logging {
channel query_log {
file "query.log";日志名
severity info;级别 和syslog差不多的那种
print-time yes;
print-category yes;
};
category queries {#分类Once a customized channel has been defined, a category option is used to categorize the channel and begin logging when named is restarted
query_log;
};
};
forwarders {
221.228.255.1;159.226.5.65;
};#我解析不了就给他
};
include "acl.conf";
match-clients {xxx; }; #在acl.conf中定义
recursion no;
zone "." {
type hint;
file "named.root"; #dig >named.root 或者这下:ftp://ftp.rs.internic.net/domain/
};全球的根域名服务器
zone "0.0.127.IN-ADDR.ARPA" {
type master;
file "localhost.rev"; #sh make-localhost
1 ; serial
28800 ; refresh 告诉某个区的辅域名服务器相隔多久检查该区的数据是否是最新的
7200 ; retry 如果辅域名服务器超过刷新时间后无法访问主域名服务器 那么就每隔一段重试时间就试着联系一次,重试时间通常比刷新时间要短
604800 ; expire 如果期满时间内辅助域名服务器还是无法与主域名服务器联系上 那么就宣布这个区失效,停止关于该区的任何查询应答
86400 ; ttl 否定缓存ttl值
)
IN NS localhost.
};
zone "fashionfree.cn"{
type master;
file "fashionfree.fwd";
};
#zone "0.168.192.in-addr.arpa" {
# type master;
# file "master/test75.rev";
#};
algorithm hmac-md5;
secret "YMVkQroow6D4rYGffjOkQw==";
};
controls {
inet 127.0.0.1/* port 953
allow { 127.0.0.1/any; } keys { "rndc-key"; };
};这决定rndc用户要用什么加密密钥来验证身份才能给域名服务器发送控制消息
rndc 是 bind 软件引进的远程控制通道,代替 unix 信号来控制 named 进程,可以用来对配置进行重新载入
#named -c named.conf
58.16.0.0/16;
一般客户机和服务器之间属递归查询,即当客户机向DNS服务器发
2.迭代查询(反复查询):
一般DNS服务器之间属迭代查询,如:若DNS2不能响应DNS
举例:比如学生问老师一个问题,王老师告诉他答案这之间的叫递归
然而,教育的要旨,不在於接受而在於懷疑。
ns 授權很簡單...
假設你註冊的 domain 叫 abc.com ,而你有 ns1 與 ns2 兩台 server 。
那,你必需從 .com 的權威伺服器授權給你,其設定或類似如此:
然後,你的 ns1 或 ns2 都可是權威伺服器了(各自的 SOA 設為自己即可)。
在 abc.com 的 db 中,最少還應類似如下的設定:
不過,既然 SOA 是自己的話,那事實上,我可以改變 ns 或增加 ns 授權:
假如你有 sub-zone 要授權,事實上也是利用 ns 啦:
然而,不同版本的 resolver ,對最終的 ns 判定是不一樣的:
bind9 是以 abc.com 的權威主機的 ns 為依據,若找不到,那就沒結果。
而之前的版本,則可退而求次,以 com. 裡關於 abc.com 的 ns 為答案。
zone "mydomain.com" {
type master;
file "mydomain.com.zone";
notify yes;
allow-transfer { slave_servers; };
also-notify { slave_servers; };
};
If yes (the default), DNS NOTIFY messages are sent when a zone the server is authoritative for
changes, see Section 3.3. The messages are sent to the servers listed in the zone’s NS records
(except the master server identified in the SOA MNAME field), and to any servers listed in the
also-notify option.
If explicit, notifies are sent only to servers explicitly listed using also-notify. If no, no notifies
are sent.
The notify option may also be specified in the zone statement, in which case it overrides the options
notify statement. It would only be necessary to turn off this option if it caused slaves to crash.
6.2.14.6
also-notify
Defines a global list of IP addresses of name servers that are also sent NOTIFY messages whenever
a fresh copy of the zone is loaded, in addition to the servers listed in the zone’s NS records. This
helps to ensure that copies of the zones will quickly converge on stealth servers. If an also-notify
list is given in a zone statement, it will override the options also-notify statement. When a zone
notify statement is set to no, the IP addresses in the global also-notify list will not be sent NOTIFY
messages for that zone. The default is the empty list (no global notification list).
使用notify指令会自动通知所有这个域的所有在ns记录上的机器,also-notify指令可以用来通知所有不在ns记录上的dns服务器。



