[iyunv@school ~]# tar xf bind-9.9.5.tar.gz #解压
[iyunv@school ~]# cd bind-9.9.5 #进入目录
应该以普通用户运行,所以创建普通用户
1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@school bind-9.9.5]# id named #查看named用户是否存在
id: named: No such user
[iyunv@school bind-9.9.5]# groupadd -r -g 53 named #创建named组
[iyunv@school bind-9.9.5]# useradd -g named -r -u 53 named #创建named用户
[iyunv@school bind-9.9.5]# id named #查看named用户信息
uid=53(named) gid=53(named) groups=53(named)
编译安装
[iyunv@school bind-9.9.5]# ./configure --prefix=/usr/local/bind9 --sysconfdir=/etc/named/ --enable-threads --disable-chroot --disable-ipv6
[iyunv@school bind-9.9.5]# make && make install
选项:
--enable-threads #启用多线程功能
--disable-chroot #不启用chroot功能
--disable-ipv6 #不启用ipv6
[iyunv@school named]# vim localhost.zone
$TTL 86400
@ IN SOA localhost. admin.localhost. (
2015072301
3H
15M
7D
1D )
IN NS localhost.
IN A 127.0.0.1
[iyunv@school named]# vim 127.0.0.zone
$TTL 86400
@ IN SOA localhost. admin.localhost. (
2015072301
3H
15M
7D
1D )
IN NS localhost.
IN PTR localhost.
更改属主属组
1
2
3
4
5
6
7
8
[iyunv@school named]# chgrp named 127.0.0.zone localhost.zone named.ca
[iyunv@school named]# chmod 640 127.0.0.zone localhost.zone named.ca
[iyunv@school named]# ll
total 16
-rw-r-----. 1 root named 133 Jul 23 19:50 127.0.0.zone
-rw-r-----. 1 root named 129 Jul 23 19:48 localhost.zone
-rw-r-----. 1 root named 2177 Jul 23 19:45 named.ca
drwxrwx---. 2 named named 4096 Jul 23 19:39 slaves
检查配置文件、区域文件语法错误
1
2
3
4
5
6
7
[iyunv@school named]# named-checkconf /etc/named/named.conf
[iyunv@school named]# named-checkzone "localhost" /var/named/localhost.zone
zone localhost/IN: loaded serial 20150723
OK
[iyunv@school named]# named-checkzone "0.0.127.in-addr.arpa" /var/named/127.0.0.zone
zone 0.0.127.in-addr.arpa/IN: loaded serial 20150723
OK
启动
1
[iyunv@school named]# named -g -u named -c /etc/named/named.conf
添加区域解析库文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[iyunv@school named]# vim /etc/named/named.conf
zone "school.com" IN {
type master;
file "school.com.zone";
allow-transfer {192.168.0.0/24; 127.0.0.1; };
allow-update { none; };
};
[iyunv@school named]# vim /var/named/school.com.zone
$TTL 3600
@ IN SOA ns.school.com. admin.school.com. (
2015072301
1H
10M
7D
1D )
IN NS ns
ns IN A 192.168.0.9
www IN A 192.168.0.15
[iyunv@school named]# killall -HUP named
[iyunv@school named]# rndc reload
server reload successful
[iyunv@school named]# rndc status
version: 9.9.5 <id:f9b8a50e>
CPUs found: 4
worker threads: 4
UDP listeners per interface: 4
number of zones: 101
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
recursive clients: 0/0/1000
tcp clients: 0/100
server is up and running
改属主属组
1
2
[iyunv@school named]# chmod 440 rndc.conf
[iyunv@school named]# chgrp named rndc.conf