DNS的作用正向解析、反向解析。。。
Full Qualified Domain Name 安全合格主机名 = 主机名。域名 比如,www.tarena.com.cn
执行程序:/usr/sbin/named 服务脚本:/etc/init.d/named 默认端口:TCP/UDP 53
虚拟根环境:/var/named/chroot/ 主配置文件:/etc/named.conf 区域数据文件:/var/named/
DNS 日志 /var/log/messages
一、构建主DNS
[root@songchunhui ~]# yum -y install bindbind-chroot caching-nameserver
[root@songchunhui ~]# service named restart
[root@songchunhui ~]# chkconfig named on
[root@songchunhui ~]# cd/var/named/chroot/etc/
[root@songchunhui etc]# cp -p named.caching-nameserver.confnamed.conf
[root@songchunhui etc]# vim named.conf
options { 定义全局选项
listen-on port 53 { 192.168.3.100; };监听地址和端口
listen-on-v6 port 53 { ::1; };
directory "/var/named";地址文件的默认位置(区域数据文件)
allow-transfer { 192.168.3.11; }; 授权从DNS服务器
…………
allow-query { any; };允许所有客户机查询
allow-query-cache { any; };
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
[root@songchunhui etc]# vimnamed.rfc1912.zones
zone"tarena.com" IN { 正向解释区域 tarena.com 是域名
type master; 类型为主解释区域
file "tarena.com.zone"; 主解释区域地址数据文件
};
zone"3.168.192.in-addr.arpa" IN { 设置反向解析区域
type master;
file "tarena.com.arpa";
};
[root@songchunhui etc]# named-checkconf/var/named/chroot/etc/named.conf 无错误,无输出
[root@songchunhui etc]# cd/var/named/chroot/var/named/ 区域数据地址
[root@songchunhui named]# cp -p named.localtarena.com.zone
[root@songchunhui named]# vimtarena.com.zone
$TTL 86400 有效生存周期
@ IN SOA dns01.tarena.com.root.tarena.com. (
2014062501 ; Serial 更新序号
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400) ; Minimum
IN NS dns01.tarena.com. 域名服务器NS
IN NS dns02.tarena.com.
IN A 192.168.3.100
dns01 IN A 192.168.3.100
dns02 IN A 192.168.3.11
www IN A 192.168.3.100 轮询DNS配置,DNS的负载均衡
www IN A 192.168.3.11 轮询DNS配置,DNS的负载均衡
bbs IN A 1.1.1.2
ftp IN CNAME www 别名记录
* IN A 192.168.3.100 *泛域名解析
$GENERATE 20-50 station$IN A 192.168.3.$ 分配对应的DNS和主机名
[root@songchunhui named]# cp -ptarena.com.zone tarena.com.arpa
[root@songchunhui named]# vimtarena.com.arpa
$TTL 86400
@ IN SOA dns01.tarena.com.root.tarena.com. (
2014062501 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400) ; Minimum
IN NS dns01.tarena.com.
IN NS dns02.tarena.com.
100 IN PTR dns01.tarena.com. 指针记录RTP
100 IN PTR dns02.tarena.com.
2 IN PTR mail.tarena.com.
5 IN PTR www.tarena.com.
[root@songchunhui named]# named-checkzonetarena.com tarena.com.zone 区域地址文件语法是否正确
zone tarena.com/IN: loaded serial2014062501
OK
[root@songchunhui named]# named-checkzonetarena.com tarena.com.arpa
zone tarena.com/IN: loaded serial2014062501
OK
本机进行测试
[root@songchunhui etc]# dig [email protected]
[root@songchunhui etc]# host www.tarena.com192.168.3.100
二、构建从DNS
[root@dengziqi ~]# yum -y remove bindbind-chroot caching-nameserver
[root@dengziqi ~]# service named restart
[root@dengziqi ~]# chkconfig named on
[root@dengziqi ~]# cd/var/named/chroot/etc/
[root@dengziqi etc]# cp -p named.caching-nameserver.confnamed.conf
[root@dengziqi etc]# vim named.conf
15 listen-on port 53 { 192.168.3.11; };
27 allow-query { any; };
28 allow-query-cache { any; };
37 match-clients { any; };
38 match-destinations { any; };
[root@dengziqi etc]# vimnamed.rfc1912.zones
50 zone"tarena.com" IN {
51 type slave;区域类型改为slave
52 file "slaves/tarena.com.zone";改为保存到slaves/子目录下
53 masters { 192.168.3.100; };
54 };
55 zone "3.168.192.in-addr.arpa" IN{
56 type slave;
57 file "slaves/tarena.com.arpa";
58 masters { 192.168.3.100; };
59 };
[root@dengziqi etc]# named-checkconfnamed.conf
[root@dengziqi etc]# service named restart
[root@dengziqi etc]# ls /var/named/chroot/var/named/slaves/
tarena.com.arpa tarena.com.zone
进行测试
[root@dengziqi slaves]# host www.tarena.com192.168.3.100
[root@dengziqi slaves]# hostdns02.tarena.com 192.168.3.100
[root@dengziqi slaves]# dig www.tarena.com192.168.3.100
客户端DNS设置
vim /etc/resolv.conf
nameserver 192.168.3.100
nameserver 192.168.3.11