安装环境:
Fedora 4
bind-9.2.6.tar.gz
卸载系统自带的bind服务:
一、安装BIND
1、准备工作
下载稳定的BIND服务器进行安装,下载地址:www.isc.org
wget http://ftp.isc.org/isc/bind9/9.2.6/bind-9.2.6.tar.gz
安装gcc
2 、编译安装BIND
配置BIND
二、配置根服务器
1、修改配置文件
2、建立工作目录
3、查询根DNS服务器
# dig -t NS .
; <<>> DiG 9.2.6 <<>> -t NS .
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- op QUERY, status: NOERROR, id: 28940
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 139616 IN NS G.ROOT-SERVERS.NET.
. 139616 IN NS H.ROOT-SERVERS.NET.
. 139616 IN NS I.ROOT-SERVERS.NET.
. 139616 IN NS J.ROOT-SERVERS.NET.
. 139616 IN NS K.ROOT-SERVERS.NET.
. 139616 IN NS L.ROOT-SERVERS.NET.
. 139616 IN NS M.ROOT-SERVERS.NET.
. 139616 IN NS A.ROOT-SERVERS.NET.
. 139616 IN NS B.ROOT-SERVERS.NET.
. 139616 IN NS C.ROOT-SERVERS.NET.
. 139616 IN NS D.ROOT-SERVERS.NET.
. 139616 IN NS E.ROOT-SERVERS.NET.
. 139616 IN NS F.ROOT-SERVERS.NET.
;; ADDITIONAL SECTION:
J.ROOT-SERVERS.NET. 485712 IN A 192.58.128.30
;; Query time: 51 msec
;; SERVER: 172.xx.xx.11#53(172.xx.xx.11)
;; WHEN: Tue Feb 14 01:55:39 2006
;; MSG SIZE rcvd: 244
#
#echo "nameserver 192.58.128.30" >/etc/resolv.conf
#
4、将跟记录加入到/etc/resolv.conf文件中
5、将跟服务器的信息导入到/var/bind/named.ca文件中
#dig -t NS . >/var/bind/named.ca
#cat /var/bind/named.ca
; <<>> DiG 9.2.6 <<>> -t NS .
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- op QUERY, status: NOERROR, id: 16471
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 13
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 517472 IN NS M.ROOT-SERVERS.NET.
. 517472 IN NS A.ROOT-SERVERS.NET.
. 517472 IN NS B.ROOT-SERVERS.NET.
. 517472 IN NS C.ROOT-SERVERS.NET.
. 517472 IN NS D.ROOT-SERVERS.NET.
. 517472 IN NS E.ROOT-SERVERS.NET.
. 517472 IN NS F.ROOT-SERVERS.NET.
. 517472 IN NS G.ROOT-SERVERS.NET.
. 517472 IN NS H.ROOT-SERVERS.NET.
. 517472 IN NS I.ROOT-SERVERS.NET.
. 517472 IN NS J.ROOT-SERVERS.NET.
. 517472 IN NS K.ROOT-SERVERS.NET.
. 517472 IN NS L.ROOT-SERVERS.NET.
;; ADDITIONAL SECTION:
A.ROOT-SERVERS.NET. 603872 IN A 198.41.0.4
B.ROOT-SERVERS.NET. 603872 IN A 192.228.79.201
C.ROOT-SERVERS.NET. 603872 IN A 192.33.4.12
D.ROOT-SERVERS.NET. 603872 IN A 128.8.10.90
E.ROOT-SERVERS.NET. 603872 IN A 192.203.230.10
F.ROOT-SERVERS.NET. 603872 IN A 192.5.5.241
G.ROOT-SERVERS.NET. 603872 IN A 192.112.36.4
H.ROOT-SERVERS.NET. 603872 IN A 128.63.2.53
I.ROOT-SERVERS.NET. 603872 IN A 192.36.148.17
J.ROOT-SERVERS.NET. 603872 IN A 192.58.128.30
K.ROOT-SERVERS.NET. 603872 IN A 193.0.14.129
L.ROOT-SERVERS.NET. 603872 IN A 198.32.64.12
M.ROOT-SERVERS.NET. 603872 IN A 202.12.27.33
;; Query time: 478 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Feb 14 12:21:35 2006
;; MSG SIZE rcvd: 436
6、配置rndc
#rndc-confgen >/etc/bind/rndc.conf
# cat -n /etc/bind/rndc.conf
# Start of rndc.conf
key "rndc-key" {
algorithm hmac-md5;
secret "OJuPxS0u/5tJ71W8ypj4fA==";
};
options {
default-key "rndc-key";
default-server 127.0.0.1;
default-port 953;
};
# End of rndc.conf
# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndc-key" {
# algorithm hmac-md5;
# secret "OJuPxS0u/5tJ71W8ypj4fA==";
# };
#
# controls {
# inet 127.0.0.1 port 953
# allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf
7、将rndc中的部分记录导入到/etc/bind/named.conf文件中,并修改/etc/bind/named.conf,将导入的配置前面的注释去掉。
8、检查并重新启动named服务,查看日志文件并检查rndc访问状态
9、修改/etc/bind/named.conf,并使用host命令测试
三、配置localhost区域
(一)、配置localhost的正向区域
1、修改/etc/bind/named.conf,插入如下内容
2、配置/var/bind/db.local;
3、测试
# dig localhost
; <<>> DiG 9.2.6 <<>> localhost
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- op QUERY, status: NOERROR, id: 27414
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;localhost. IN A
;; ANSWER SECTION:
localhost. 86400 IN A 127.0.0.1
;; AUTHORITY SECTION:
localhost. 86400 IN NS localhost.
;; Query time: 52 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Feb 14 13:06:21 2006
;; MSG SIZE rcvd: 57
# dig -t NS localhost
; <<>> DiG 9.2.6 <<>> -t NS localhost
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- op QUERY, status: NOERROR, id: 13067
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;localhost. IN NS
;; ANSWER SECTION:
localhost. 86400 IN NS localhost.
;; ADDITIONAL SECTION:
localhost. 86400 IN A 127.0.0.1
;; Query time: 44 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Feb 14 13:07:54 2006
;; MSG SIZE rcvd: 57
# dig -t A localhost
; <<>> DiG 9.2.6 <<>> -t A localhost
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- op QUERY, status: NOERROR, id: 31098
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;localhost. IN A
;; ANSWER SECTION:
localhost. 86400 IN A 127.0.0.1
;; AUTHORITY SECTION:
localhost. 86400 IN NS localhost.
;; Query time: 42 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Feb 14 13:08:00 2006
;; MSG SIZE rcvd: 57