一、下载BIND
本次实验下载的版本是:BIND 9.11.0-P2
二、安装BIND
1、进入压缩包的目录,进行解压缩,进入bind目录。
[root@TEST opt]# tar zxvf bind-9.11.0-P2.tar.gz
[root@TEST opt]# cd bind-9.11.0-P
2、编译配置
[root@TEST bind-9.11.0-P2]# ./configure --prefix=/data/sdns/named --enable-threads #--enable-threads开启多线程处理能力
[root@TEST bind-9.11.0-P2]#make
[root@TEST bind-9.11.0-P2]#make install
3、建立配置文件
[root@TEST named]# cd /data/sdns/named
4、生成rndc控制命令的key文件
[root@TEST named]# sbin/rndc-confgen > etc/rndc.conf
5、从rndc.conf中提取named.conf用的key
[root@TEST named]#tail -10 etc/rndc.conf | head -9 | sed s/#\ //g > etc/named.conf
6、配置named.conf
[root@TEST named]#vim /data/sdns/named/etc/named.conf
增加
options {
directory "/data/sdns/zone/";
pid-file "named.pid";
};
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" IN {
type master;
file "test.zone";
allow-update { none; };
};
7、建立区目录文件
[root@TEST named]#mkdir /data/sdns/zone
[root@TEST named]#cd /data/sdns/zone
A、建立localhost.zone文件
[root@TEST named]#vim localhost.zone
增加
$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS @
1D IN A 127.0.0.1
B、建立named.local文件
[root@TEST named]#vim 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.
C、建立test.zone文件
[root@TEST named]#vim test.zone
增加
$ttl 1D
@ IN SOA test.com. root.test.com. (
1053891162
3H
15M
1W
1D )
IN NS ns.test.com.
IN MX 5 test.com.
IN A 3.3.3.3
ns IN A 1.2.3.4
www IN A 220.202.19.82
D、dig命令直接生成named.root文件
[root@TEST named]#dig > named.root
8、启动bind
[root@TEST named]#/data/sdns/named/sbin/named -c /data/sdns/named/etc/named.conf &
9、重新加载配置文件(常用命令,修改了配置文件,就可以用这个命令来更新)
[root@TEST named]#/data/sdns/named/sbin/rndc reload
10、测试
[root@TEST named]#dig @127.0.0.1 test.com
本文出自 “他山之石” 博客,请务必保留此出处http://zhangshujie.blog.51cto.com/4921537/1894671
原文地址:http://zhangshujie.blog.51cto.com/4921537/1894671