以下文章转载自http://blog.csdn.net/whhgd6370/article/details/6257445
Bind版本:目前来说最新版,9.8.0
1.安装:http://www.isc.org/software/bind/980/download/下载tar安装包,并解压后放在/home/目录下
命令:tar zxvf bind-9.8.0.tar.gz
cd bind-9.4.0
./configure sysconfdir=/etc //更多安装选项configure --help(本条命令表示把bind的配置文件路径设置为/etc)
(注:这里一般由于DNSEC功能需要使用SSL协议,所以默认配置会检查openssl的配置,我这里不使用ssl了 加上--without openssl即可,即:./configure sysconfdir=/etc --without openssl)
make
make install
2.配置:
(1)首先需要建立配置文件,共有两个:./etc/named.conf和./etc/rndc.conf
命令:rndc-confgen > /etc/rndc.conf
会自动生成rndc.conf文件中的内容,我生成的rndc.conf文件的内容为:
# Start of rndc.conf
key "rndc-key" {
algorithm hmac-md5;
secret "7Tp+AIcREtlzhfR4MU9W9Q==";
};
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 "7Tp+AIcREtlzhfR4MU9W9Q==";
# };
#
# controls {
# inet 127.0.0.1 port 953
# allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf
然后手动建立named.conf文件,其内容为:
options {
directory "/var/named";
// pid-file "/var/run/named/named.pid"; //运行的PID文件路径,用于使用其他用户启动named
};
zone "." {
type hint;
file "named.ca";
};
zone "localhost" {
type master;
file "named.local";
};
//其实最主要的是上面的三个文件
zone "example.com"
{ //创建 example.com域
type master;
file "example.com.zone";
};
zone "0.0.127.in-addr.arpa"
{ //localhost的反解析
type master;
file "127.0.0.zone";
};
zone "100.168.192.in-addr.arpa"
{ //example.com的反向解析
type master;
file "192.168.100.zone";
};
#注:这一部分为从生成的/etc/rndc.conf 的尾部拷贝过来并去掉某些注释符号的结果
# Use with the following in named.conf, adjusting the allow list as needed:
key "rndc-key" {
algorithm hmac-md5;
secret "7Tp+AIcREtlzhfR4MU9W9Q==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
# End of named.conf
$TTL 1D
@ IN SOA localhost. root (
2007042801
1H
15M
1W
1D )
IN NS @
IN A 127.0.0.1
example.com.zone中内容:
$TTL 1D
@ IN SOA example.com. root (
2007042801
1H
15M
1W
1D )
IN NS ns.example.com.
IN MX 10 mail.example.com.
IN A 192.168.100.125
www IN A 192.168.100.125
db IN A 192.168.100.124
ns IN A 192.168.100.126
mail IN A 192.168.100.251
shop IN A 192.168.100.125
*.shop IN A 192.168.100.124
news IN CNAME www
127.0.0.zone中内容:
@ IN SOA @ root.localhost. (
2007042801
1H
15M
1W
1D
)
IN NS localhost.
1 IN PTR localhost.
@ IN SOA @ root.example.com. (
2007042801
1H
15M
1W
1D )
IN NS example.com.
125 IN PTR example.com.
125 IN PTR www.example.com.
124 IN PTR db.example.com.
126 IN PTR ns.example.com.
251 IN PTR mail.example.com.