操作系统:RedHat5.8
软件安装:
#yum install bind bind-utils bind-chroot caching-nameserver
软件启动:
#/etc/init.d/named start
#chkconfig named on
软件配置:
1)ex:
#vim /var/named/chroot/etc/named.conf --> dns服务器主配置文件
options {
directory "/var/named";
};
zone "linux.com" {
type master;
file "linux.com.zone";
}; --> 正向解析
zone "1.168.192.in-addr.arpa" {
type master;
file "1.168.192.arpa";
}; --> 反向解析
zone "." IN {
type hint;
file "named.ca";
}; --> 根域
#vim /var/named/chroot/var/named/linux.com.zone
--> dns服务器正向解析区域配置文件
$TTL 86400
@IN SOA dns.linux.com. root.linux.com. (
201372301
3H
15M
1W
1D )
IN NS dns.linux.com.
dns.linux.com. IN A 192.168.1.100
server1.linux.com. IN A 192.168.1.101
ftp IN CNAME server1
mail IN CNAME server1
linux.com. IN MX 10 mail.linux.com
linux.com. IN MX 11 mail1.linux.com
server2.linux.com. IN A 192.168.1.102
server2.linux.com. IN A 192.168.1.103
server2.linux.com. IN A 192.168.1.104
*.linux.com. IN A 192.168.1.105
#vim /var/named/chroot/var/named/1.168.192.arpa
--> dns服务器反向解析区域配置文件
$TTL 86400
@IN SOAdns.linux.com. root.linux.com. (
201372301
3H
15M
1W
1D )
IN NS dns.linux.com.
111 IN PTR server11.linux.com.
112 IN PTR server12.linux.com.
1-1) 只缓存DNS服务器--> 完全转发
ex:
#vim /var/named/chroot/etc/named.conf
options {
directory "/var/named";
forward only;
--> 只使用forwarders DNS服务器做域名解析,查询不到则返回DNS客户端查询失败
forwarders { 192.168.1.110;192.168.1.112; };
--> 设置将DNS请求转发到哪个服务器,可以指定多个服务器IP地址
};
1-2)转发DNS服务器--> 完全转发
ex:
#vim /var/named/chroot/etc/named.conf
options {
directory "/var/named";
recursion yes;
--> 允许递归,转发服务器查询模式必须允许递归,否则无法正确完成转发
forward first;
--> 优先使用forwarders DNS服务器做域名解析,查询不到使用本地DNS服务器做域名解析
forwarders { 192.168.1.110;192.168.1.112; };
};
1-3) 访问未经授权的DNS域--> 部分转发
ex:
#vim /var/named/chroot/etc/named.conf
zone "b.com" IN {
type forward;
forward { IP; };--> IP为b.com域的DNS主机IP地址
}
2) 主从DNS服务器/主辅DNS服务器
ex:
主dns服务器
#vim /var/named/chroot/etc/named.conf --> 主dns服务器主配置文件
options {
directory "/var/named";
};
zone "linux.com" {
type master;
file "linux.com.zone";
--> 配置从DNS时需下面两行
notify yes;
allow-transfer { 192.168.1.104; };
}; --> 正向解析
zone "1.168.192.in-addr.arpa" {
type master;
file "1.168.192.arpa";
notify yes;
allow-transfer { 192.168.1.104; };
}; --> 反向解析
zone "." IN {
type hint;
file "named.ca";
}; --> 根域
#vim /var/named/chroot/var/named/linux.com.zone
--> 主dns服务器正向解析区域配置文件
$TTL 86400
@IN SOA dns.linux.com. root.linux.com. (
201372301
3H
15M
1W
1D )
IN NS dns.linux.com.
dns.linux.com. IN A 192.168.1.100
server1.linux.com. IN A 192.168.1.101
ftp IN CNAME server1
mail IN CNAME server1
linux.com. IN MX 10 mail.linux.com
linux.com. IN MX 11 mail1.linux.com
server2.linux.com. IN A 192.168.1.102
server2.linux.com. IN A 192.168.1.103
server2.linux.com. IN A 192.168.1.104
*.linux.com. IN A 192.168.1.105
#vim /var/named/chroot/var/named/1.168.192.arpa
--> 主dns服务器反向解析区域配置文件
$TTL 86400
@IN SOAdns.linux.com. root.linux.com. (
201372301
3H
15M
1W
1D )
IN NS dns.linux.com.
111 IN PTR server11.linux.com.
112 IN PTR server12.linux.com.
辅/从dns服务器
#vim /var/named/chroot/etc/named.conf
--> 辅/从dns服务器主配置文件(辅/从dns不需要区域配置文件)
options {
directory "/var/named";
};
zone "linux.com" {
type slave;
file "slave.linux.zone";
masters { 192.168.1.100; };
};
zone "1.168.192.in-addr.arpa" {
type slave;
file "1.168.192.arpa";
masters { 192.168.1.100; };
};
zone "." IN {
type hint;
file "named.ca";
};
相关文章:
CentOS中DNS服务器的搭建:http://www.linuxdiyf.com/linux/11420.html
在CentOS7.0上搭建Chroot的Bind DNS服务器:http://www.linuxdiyf.com/linux/10212.html
CentOS上配置主DNS服务器的简易指南:http://www.linuxdiyf.com/linux/10661.html