0. 网卡地址192.168.1.198
A 纪录 www.test.com.cn 192.168.1.198
ftp.test.com.cn 192.168.1.198
test.com.cn 192.168.1.198
MX纪录 test.com.cn
尤其注意:严格按照格式写,符号不能多也不能少,否则无法成功,bind的日志在/var/named/log/bindall.log中,可以看里面的提示,哪里出现了问题;
1.从http://www.isc.org/products/BIND/下载bind9的源文件。我下载的是9.2.5
2.将源文件bind-9.2.5.tar.gz置于/home/bind9目录下。
3.解压缩源文件bind-9.2.5.tar.gz
# tar -xzvf bind-9.2.5.tar.gz
4.进入安装目录
# cd bind-9.2.5
5.配置、编译
# ./configure
# make
6.安装
# make install
7.生成的可执行文件位于/usr/local/sbin目录下,用到的文件名为named、rndc;
8.生成rndc控制命令的key文件
# /usr/local/sbin/rndc-confgen > etc/rndc.conf
9.创建rndc.key文件,
#cat rndc.conf > rndc.key
按照rndc.key文件的提示,可以将文件的前面部分删除,留下文件后面部分中的注释部分,同时将注释符去掉即可,如下:
key "rndc-key" {
algorithm hmac-md5;
secret "y9xvvfQjdWv9f/Fo7wquBg==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
10. 建立/etc/name.conf文件
options {
directory "/var/named";
listen-on ;
};
logging {
channel syslog_info{
file "/var/named/log/bindall.log" versions 20 size 2m;
print-category yes;
print-time yes;
severity notice;
};
category default {
syslog_info;
};
};
zone "." IN {
type hint;
file "named.root";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "test.com.cn" {
type master;
file "named.test.com.cn";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" {
type master;
file "named.1.168.192";
allow-update { none; };
};
include "/etc/rndc.key";
11 利用下载工具下载文件name.root,地址为ftp://FTP.RS.INTERNIC.NET/domain/named.root,
或者用命令生成#dig > /var/named/named.root,内容如下:
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 198.32.64.12
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
12 建立目录/var/named和/var/named/log,在/var/named/下分别建立如下文件:
1)localhost.zone
$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root (
42 ;serial
3H ;refresh
15M ;retry
1W; expiry
1D ;minimum
);
1D IN NS @
1D IN A 127.0.0.1
2)named.local
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700;serial
28800 ;refresh
14400 ;retry
3600000 ;expire
86400 ) ;minimum
IN NS localhost.
1 IN PTR localhost.
3)named.1.168.192
$TTL 86400
@ IN SOA test.com.cn. root.test.com.cn. (
2003061800;serial
28800 ;refresh
14400 ;retry
3600000 ;expire
86400 ) ;minimum
@ IN NS test.com.cn.
198 IN PTR www.test.com.cn.
198 IN PTR ftp.test.com.cn.
4)named.test.com.cn
$TTL 86400
@ IN SOA test.com.cn. root.test.com.cn. (
2003061800;serial
28800 ;refresh
14400 ;retry
3600000 ;expire
86400 ) ;minimum
@ IN NS test.com.cn.
www IN A 192.168.1.198
ftp IN A 192.168.1.198
test.com.cn IN A 192.168.1.198
test.com.cn IN MX 5 192.168.1.198 ;设置test.com.cn域名mx纪录,优先级别为5,数值越低级别越高
13. 修改/etc/host.conf文件,内容如下:
order bind,hosts
14.修改/etc/resolv.conf文件,内容如下:
nameserver 192.168.1.198
15.运行
#/usr/local/sbin/named -c /etc/named.conf &
16.修改bind的配置文件后,如果不重启named进程,可以执行命令使named进程重新读取配置文件,#rndc reload,这样修改后的配置文件即刻生效;