一、下载BIND
本次实验下载的版本是:BIND 9.11.0-P2
二、安装BIND
1、进入压缩包的目录,进行解压缩,进入bind目录。
[[email protected] opt]# tar zxvf bind-9.11.0-P2.tar.gz
[[email protected] opt]# cd bind-9.11.0-P
2、编译配置
[[email protected] bind-9.11.0-P2]# ./configure --prefix=/data/sdns/named --enable-threads #--enable-threads开启多线程处理能力
[[email protected] bind-9.11.0-P2]#make
[[email protected] bind-9.11.0-P2]#make install
3、建立配置文件
[[email protected] named]# cd /data/sdns/named
4、生成rndc控制命令的key文件
[[email protected] named]# sbin/rndc-confgen > etc/rndc.conf
5、从rndc.conf中提取named.conf用的key
[[email protected] named]#tail -10 etc/rndc.conf | head -9 | sed s/#\ //g > etc/named.conf
6、配置named.conf
[[email protected] 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、建立区目录文件
[[email protected] named]#mkdir /data/sdns/zone
[[email protected] named]#cd /data/sdns/zone
A、建立localhost.zone文件
[[email protected] 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文件
[[email protected] 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文件
[[email protected] 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文件
[[email protected] named]#dig > named.root
8、启动bind
[[email protected] named]#/data/sdns/named/sbin/named -c /data/sdns/named/etc/named.conf &
9、重新加载配置文件(常用命令,修改了配置文件,就可以用这个命令来更新)
[[email protected] named]#/data/sdns/named/sbin/rndc reload
10、测试
[[email protected] named]#dig @127.0.0.1 test.com