DNS缓存服务器多存在于小型企业内,它们不负责域名解析,只用来帮助用户向其它DNS服务器进行域名信息查询。并把查询到的信息保存在本地,方便下次使用,缩短域名查询时间,保存再本地的信息是有有效期的。
下面是具体配置:
# wget
ftp://192.168.1.31/bind-9.8.1.tar.gz 下载源码包
# tar zxvf bind-9.8.1.tar.gz 解压源码包
# cd bind-9.8.1 进入解压目录
# ./configure --prefix=/usr/local/named --enable-threads --with-openssl=no 编译前配置
# make && make install 编译并安装
# /usr/local/named/sbin/rndc-confgen > /usr/local/named/etc/rndc.conf 生成rndc控制命令的key文件
# tail -10 /usr/local/named/etc/rndc.conf |head -9|sed s/#\ //g > /usr/local/named/etc/named.conf 从rndc.conf中提取named.conf用的key
# vi /usr/local/named/etc/named.conf 编辑named.conf
# tar zxvf bind-9.8.1.tar.gz 解压源码包
# cd bind-9.8.1 进入解压目录
# ./configure --prefix=/usr/local/named --enable-threads --with-openssl=no 编译前配置
# make && make install 编译并安装
# /usr/local/named/sbin/rndc-confgen > /usr/local/named/etc/rndc.conf 生成rndc控制命令的key文件
# tail -10 /usr/local/named/etc/rndc.conf |head -9|sed s/#\ //g > /usr/local/named/etc/named.conf 从rndc.conf中提取named.conf用的key
# vi /usr/local/named/etc/named.conf 编辑named.conf
在named.conf中添加如下内容:
#指定资源文件存放路径,和pid文件名称。
options {
directory "/usr/local/named/dns/zone";
pid-file "/usr/local/named/dns/named.pid";
};
#指向跟服务器的资源文件
zone "." IN {
type hint;
file "named.root";
};
#本地权威DNS记录的资源文件
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
#本地权威反向DNS记录的资源文件
zone "0.0.127.in-addr.arpa" IN {
type master;
file "localhost.rev";
allow-update { none; };
};
options {
directory "/usr/local/named/dns/zone";
pid-file "/usr/local/named/dns/named.pid";
};
#指向跟服务器的资源文件
zone "." IN {
type hint;
file "named.root";
};
#本地权威DNS记录的资源文件
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
#本地权威反向DNS记录的资源文件
zone "0.0.127.in-addr.arpa" IN {
type master;
file "localhost.rev";
allow-update { none; };
};
# mkdir -p /usr/local/named/dns/zone 创建资源文件存放路径
# cd /usr/local/named/dns/zone/ 进去资源文件存放目录
#/usr/local/named/bin/dig |grep -v "^;"> /usr/local/named/dns/zone/named.root 使用dig命令生成named.root根服务资源文件
# cd /usr/local/named/dns/zone/ 进去资源文件存放目录
#/usr/local/named/bin/dig |grep -v "^;"> /usr/local/named/dns/zone/named.root 使用dig命令生成named.root根服务资源文件
若是不能上网的话,也可以下载网上最新的named.root文件。
named.root文件内容如下:
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:BA3E::2:30
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
D.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2D::D
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
F.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2F::F
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
H.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:1::803F:235
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
I.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FE::53
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
J.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:C27::2:30
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
K.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FD::1
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 199.7.83.42
L.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:3::42
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
M.ROOT-SERVERS.NET. 3600000 AAAA 2001:DC3::35
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:BA3E::2:30
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
D.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2D::D
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
F.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2F::F
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
H.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:1::803F:235
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
I.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FE::53
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
J.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:C27::2:30
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
K.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FD::1
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 199.7.83.42
L.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:3::42
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
M.ROOT-SERVERS.NET. 3600000 AAAA 2001:DC3::35
# vi localhost.zone 创建本地权威DNS记录的资源文件
添加如下内容:
$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
$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
# vi localhost.rev 创建本地权威反向DNS记录的资源文件
添加如下内容:
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
启动DNS服务。
#/usr/local/named/sbin/named -4