Linux网络服务之DNS(3)
Linux网络服务之DNS(3)
实验要求:
实验一 实现分离解析:
主机192.168.10.20解析www.zhy.com 结果为192.168.1.100
主机192.168.10.21解析www.zhy.com 结果为192.168.1.101
其他主机解析www.zhy.com 结果为192.168.1.102
实验步骤:
1、安装软件包
略……
2、修改配置文件
[root@localhost etc]# cat named.conf
……
acl yd { 192.168.1.20; }; //添加acl匹配该IP地址
acl lt { 192.168.1.30; };
options {
listen-on port 53 { 192.168.1.253; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
allow-query-cache { any; };
};
……
view yd_resolver {
match-clients { yd; }; //使用acl匹配的IP地址
match-destinations { any; };
recursion yes;
include "/etc/named.yd.zones"; //该IP地址查询使用的区域文件
};
view lt_resolver {
match-clients { lt; };
match-destinations { any; };
recursion yes;
include "/etc/named.lt.zones";
};
view other_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.other.zones";
};
[root@localhost etc]# cp -p named.rfc1912.zones named.yd.zone //新建区域文件
[root@localhost etc]# cp -p named.rfc1912.zones named.lt.zone
[root@localhost etc]# cp -p named.rfc1912.zones named.other.zone
[root@localhost etc]# mv named.rfc1912.zones named.rfc1912.zones.bak
[root@localhost etc]# cat named.yd.zones
……
zone "zhy.com" IN {
type master;
file "yd.zone";
};
[root@localhost etc]# cat named.lt.zones
……
zone "zhy.com" IN {
type master;
file "lt.zone";
};
[root@localhost etc]# cat named.other.zones
……
zone "zhy.com" IN {
type master;
file "other.zone";
};
[root@localhost ~]# cd /var/named/chroot/var/named/
[root@localhost named]# cat yd.zone //修改相应的解析文件
$TTL 86400
@ IN SOA zhy.com. root.zhy.com. (
2014050201 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS dns1.zhy.com.
dns1 IN A 192.168.1.253
www IN A 192.168.1.100
[root@localhost named]# cat lt.zone
$TTL 86400
@ IN SOA zhy.com. root.zhy.com. (
2014050201 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS dns1.zhy.com.
dns1 IN A 192.168.1.253
www IN A 192.168.1.101
[root@localhost named]# cat other.zone
$TTL 86400
@ IN SOA zhy.com. root.zhy.com. (
2014050201 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS dns1.zhy.com.
dns1 IN A 192.168.1.253
www IN A 192.168.1.102
3、启动服务,设置服务开机自启
[root@localhost named]# service named restart
停止 named: [确定]
启动 named: [确定]
[root@localhost ~]# chkconfig named on
4、测试
实验二 搭建缓存DNS
实验步骤:
1、修改缓存DNS配置文件
[root@localhost ~]# cd /var/named/chroot/etc/
[root@localhost etc]# vim named.conf
……
options {
listen-on port 53 { 192.168.1.252; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
forwarders { 192.168.1.253; }; //只添加这一行配置
……
2、启动服务
[root@localhost ~]# service named restart
停止 named: [确定]
启动 named: [确定]
[root@localhost ~]# chkconfig named on
3、测试
本文出自 “烟头网管” 博客,请务必保留此出处http://8838848.blog.51cto.com/8828848/1405818