linux下bind9安装配置一例

时间:2021-05-19

一,安装BIND
1.下载BIND http://" { //创建 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 的尾部需拷贝才能使用 # tail +13 /etc/rndc.conf >>/etc/named.conf
# Use with the following in named.conf, adjusting the allow list as needed:
key "rndc-key" {
algorithm hmac-md5;
secret "HWM3L+e7LWDZJJ/dJEzQEw==";
};

controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
# End of named.conf

D.在/var/named 中创建相应的数据文件 文件名由named.conf 中的file 参数制定
由named.conf可知有 named.ca, named.local, example.com.zone, 127.0.0.zone , 192.168.100.zone
1. named.ca
# dig -t NS . >/var/named/named.ca
2. named.local #vi /var/named/named.local 加入以下内容
复制代码 代码如下:
$TTL 1D
@ IN SOA localhost. root (
2007042801
1H
15M
1W
1D )
IN NS @
IN A 127.0.0.1

3. 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
3. 127.0.0.zone
$TTl 1D
@ IN SOA @ root.localhost. (
2007042801
1H
15M
1W
1D
)
IN NS localhost.
1 IN PTR localhost.
4. 192.168.100.zone
$TTL 1D
@ IN SOA @ root.example.com. (
2007042801
1H
15M
1W
1D )
IN NS example.com.
125 IN PTR example.com.
125 IN PTR .
124 IN PTR db.example.com.
126 IN PTR ns.example.com.
251 IN PTR mail.example.com.

补充说明
a. named服务器的启动问题
1. 启动 #named //以root用户启动
#named -u named //以named用户启动,必须有这个用户而且,named.pid的属主是 named
2. 更改配置后如何重启
# rndc reload
3.测试配置是否成功,可用 host, dig ,nslookup 判断

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章