linux下bind9安装配置一例
程序员文章站
2022-06-10 20:16:51
一,安装bind 1.下载bind http://www.isc.org 也可以去本站下载 bind9 dns软件。&nbs...
一,安装bind
1.下载bind http://www.isc.org 也可以去本站下载 bind9 dns软件。
2.编译安装
复制代码 代码如下:
# tar zxvf bind-9.4.0.tar.gz
# cd bind-9.4.0
# ./configure sysconfdir=/etc //更多安装选项 ./configure --help
# make
# make install
二,配置bind
a.创建需要文件
1)./etc/named.conf
# vi /etc/named.conf 推出保存即可 或 touch /etc/named.conf
2)./etc/rndc.conf
# rndc-confgen > /etc/rndc.conf
b.创建目录 /var/named
# mkdir /var/named
b.编辑/etc/named.conf 内容如下
复制代码 代码如下:
options {
directory "/var/named"; //表示默认的数据库文件在/var/named中 若没有需手动创建
// pid-file "/var/run/named/named.pid"; //运行的pid文件路径,用于使用其他用户启动named
};
zone "." { //创建root域
type hint;
file "named.ca";
};
zone "localhost" { //创建 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 的尾部需拷贝才能使用 # 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 www.example.com.
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 判断
上一篇: Netty的ByteBuf介绍
下一篇: 女性推拿三阴交穴 调理月经抗衰老