一、 环境:
Centos-6.6-x64位操作系统,IP地址:210.38.248.7
二、 安装和配置bind服务:
1. 命令:yum install bind
2. 配置:
1) 配置/etc/named.conf文件:
acl ip1{
210.38.240.0/24; //定义240网段
};
acl ip2{
210.38.248.0/24; //定义248网段
};
options {
directory "/var/named"; //服务安装目录
recursion yes; //是否开启DNS递归
};
view "first"{
match-clients {ip1;}; //匹配240网段
recursion yes;
zone "." IN {
type hint;
file "named.ca";
};
zone "a.org" IN {
type master;
file "a.org.first";
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "1.168.192";
};
};
view "second"{
match-clients {ip2;}; //匹配248网段
recursion no;
zone "." IN {
type hint;
file "named.ca";
};
zone "a.org" IN {
type master;
file "a.org.second";
};
zone "5.168.192.in-addr.arpa" IN {
type master;
file "5.168.192";
};
};
2) 建立a.org.first和a.org.second文件并配置:
->创建: touch a.org.first
Touch a.org.second
->配置:
配置a.org.first如下:
$TTL 1200
$ORIGIN a.org.
@ IN SOA ns1.a.org. admin.a.org.(
2014091301
6H
30M
15D
3D)
IN NS ns1.a.org.
IN NS ns2.a.org.
IN MX 10 mail.a.org.
ns1 IN A 192.168.1.5
ns2 IN A 192.168.1.6
mail IN A 192.168.1.7
www IN A 192.168.1.8
配置a.org.second如下:
$TTL 1200
$ORIGIN a.org.
@ IN SOA ns1.a.org. admin.a.org.(
2014091301
6H
30M
15D
3D)
IN NS ns1.a.org.
IN NS ns2.a.org.
IN MX 10 mail.a.org.
ns1 IN A 192.168.5.5
ns2 IN A 192.168.5.6
mail IN A 192.168.5.7
www IN A 192.168.5.8
配置1.168.192如下:
$TTL 86400
@ IN SOA ns1.a.org. admin.a.org.(
2014091301
6H
30M
15D
3D)
IN NS ns1.a.org.
IN PTR a.org.
5 IN PTR ns1.a.org.
6 IN PTR ns2.a.org.
7 IN PTR mail.a.org.
8 IN PTR www.a.org
配置5.168.192如下:
$TTL 86400
@ IN SOA ns1.a.org. admin.a.org.(
2014091301
6H
30M
15D
3D)
IN NS ns1.a.org.
IN PTR a.org.
5 IN PTR ns1.a.org.
6 IN PTR ns2.a.org.
7 IN PTR mail.a.org.
8 IN PTR www.a.org
->拷贝文件到/var/named目录:
#cp a.org.* /var/named
#cp 1.168.192 /var/named
#cp 5.168.192 /var/named
3. 重启:service named restart
三、测试:分别在240/248网段的电脑终端上使用命令:nslookup ns1.a.org(域名)测试,查看解析的IP地址。