使用BIND构建域名服务器
构建缓存域名服务器
1.安装bind包
# rpm -ivh --aid --force bind-*
# rpm -ivh --aid --force caching-nameservice-9.3.3-7.el5.rpm
2.建立住配置文件named.conf
# vi /var/named/chroot/etc/named.conf
options {
listen-on port 53 { 192.168.74.140;}; //设置named监听的端口号和IP地址
directory “/var/named”; //设置数据库文件默认的存放位置
dump-file “/var/named/date/cache_dump.db”; //设置缓存数据库文件位置
statistics-file “/var/named/date/named_stats.txt”; //设置状态统计文件位置
memstatitics-file “/var/named/date/named_mem_stats.txt;
query-source port 53 ;
allow-query {192.168.74.0/24;};
recursion yes ; //允许递归查询
forwarders {202.106.0.20; 202.106.148.1;}; //设置转发DNS服务器地址,将解析请求
}; //发给设置的地址
zone “.” { //设置转发器可不这种此区域
type hint ;
file “named.ca”;
};
3.启动named服务
# service named start
4.验证缓存域名服务器
# vi /etc/resolv.conf
nameserver 192.168.74.140
# nslookup
>www.baidu.com
构建主域名服务器
1.确定本机主机名、IP地址
2.建立主配置文件named.conf
# vi /var/named/chroot/etc/named.conf
options {
directory “/var/named”;
};
zone “benet.com” {
type “master” ;
file “benet.com.zone”;
allow-transfer {192.168.10.5;};
};
zone “10.168.192.in-addr.arpa” {
type master ;
file “192.168.10.arpa”;
allow-transfer “192.168.10.5;};
};
3.建立区域数据库文件
# vi /var/named/chroot/var/named/benet.com.zone
$TTL 1D
@ SOA benet.com. admin.benet.com. (
2009091101
3H
15M
1W
1D
)
IN NS ns1.benet.com.
IN MX 10 mail.benet.com.
ns1 IN A 192.168.10.1
mail IN A 192.168.10.1
wwwIN A 192.168.10.11
ftp IN CNAME www
# vi /var/named/chroot/var/named/192.168.10.arpa
$TTL 1D
@ SOA benet.com. admin.benet.com. (
2009091101
3H
15M
1W
1D
)
IN NS ns1.benet.com.
IN MX 10 mail.benet.com.
1 IN PTR ns1.benet.com.
1 IN PTR mail.benet.com.
11 IN PTR www.benet.com.
4.重新启动named服务
5.验证主域名服务器
构建从域名服务器
1.确定本机的主机名、IP地址
2.建立主配置文件
# vi /var/named/chroot/etc/named.conf
options {
directory “/var/named”;
};
zone “benet.com” {
type slave ;
masters {192.168.10.1;};
file “slaves/benet.com.zone”;
};
zone “10.168.192.in-addr.arpa” {
type slave;
masters {192.168.10.1;};
file “slaves/192.168.10.arpa”;
};
3.重新启动服务
# service named restart
4.验证从域名服务器
构建分离解析服务器
1.建立主配置文件
# vi /var/named/chroot/etc/named.conf
options {
directory “/var/named”;
};
view “LAN” {
match-clients {192.168.10.0/24;};
zone “benet.com” {
type master;
file “benet.com.zone.lan”;
};
};
view “WAN” {
match-clients {192.168.74.0/24;};
zone “benet.com” {
type master;
file “benet.com.zone.wan”;
};
};
2.分别建立对内对外解析的区域数据库文件
$TTL 1D
@ SOA benet.com. admin.benet.com. (
2009091101
3H
15M
1W
1D
)
IN NS ns1.benet.com.
IN MX 10 mail.benet.com.
ns1 IN A 192.168.10.1
mail IN A 192.168.10.1
wwwIN A 192.168.10.11
ftp IN CNAME www
# vi /var/named/chroot/var/named/benet.com.zone.wan
$TTL 1D
@ SOA benet.com. admin.benet.com. (
2009091101
3H
15M
1W
1D
)
IN NS ns1.benet.com.
IN MX 10 mail.benet.com.
ns1 IN A 192.168.74.1
mail IN A 192.168.74.1
wwwIN A 192.168.74.11
ftp IN CNAME www