搭建DNS主从服务器实验
dns主服务器端1.安装所需的软件(rhel5.5)
[root@rhel5 ~]# yum install bind* caching* -y[root@rhel5 ~]# rpm -qa |grep bind
2.修改主配置文件named.conf
[root@rhel5 ~]# cd /var/named/chroot/etc/[root@rhel5 etc]# vim named.conf[root@rhel5 etc]# cat named.conf
options {
directory "/var/named"; dump-file "/var/named/data/cache_dump.db";// recursion yes; #默认递归查询}; include "/etc/named.rfc1912.zones";zone "sw.com" IN { #正向解析 type master;
file "sw.com.zone";};zone "1.0.10.in-addr.arpa" IN { #反向解析 type master; file "10.0.1.zone";};3.创建zone配置文件
[root@rhel5 ~]# cd /var/named/chroot/var/named/[root@rhel5 named]# vim sw.com.zone[root@rhel5 named]# cat sw.com.zone
$TTL 86400
@ IN SOA rhel5.sw.com. root ( 2013080601 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum@ IN NS rhel5.sw.com.@ IN NS sb.sw.com.sb IN A 10.0.1.18
@ IN A 10.0.1.8rhel5 IN A 10.0.1.8www IN A 10.0.1.8rhel6 IN A 10.0.1.88[root@rhel5 named]# vim 10.0.1.zone[root@rhel5 named]# cat 10.0.1.zone
$TTL 86400
@ IN SOA rhel5.sw.com. root ( 2013080601 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum@ IN NS rhel5.sw.com.@ IN NS sb.sw.com.8 IN PTR rhel5.sw.com.
18 IN PTR sb.sw.com.88 IN PTR rhel6.sw.com.4.修改默认dns服务器地址
[root@rhel5 ~]# vim /etc/resolv.conf[root@rhel5 ~]# cat /etc/resolv.confnameserver 10.0.1.8
#查看本机时间
[root@rhel5 ~]# date
2013年 08月 04日 星期日 15:21:45 CST
5.重启服务
[root@rhel5 ~]# service named restart停止 named: [确定]启动 named: [确定]
#开机自启动
[root@rhel5 ~]# chkconfig named onDNS从服务器1.安装所需软件
[root@sb ~]# yum install bind* -y[root@sb ~]# yum install "wireshark*" -y
2.修改主配置文件
[root@sb ~]# cd /var/named/slaves/[root@sb slaves]# vim /etc/named.conf[root@sb slaves]# cat /etc/named.conf
options {
directory "/var/named";};zone "sw.com" IN { type slave; file "slaves/sw.com.zone"; masters {10.0.1.8;};};zone "1.0.10.in-addr.arpa" IN { type slave; file "slaves/10.0.1.zone"; masters {10.0.1.8;};
3.主从同步时间
[root@sb ~]# yum install xinetd -y[root@sb ~]# chkconfig time-stream on[root@sb ~]# rdate -s 10.0.1.8[root@sb ~]# date2013年 08月 04日 星期日 15:23:19 CST
4.重启服务
[root@sb slaves]# service named restartStopping named: [ OK ]Starting named: [ OK ]
#从主服务器同步两个zone文件
#以后主服务器做修改并且改大Serial,主服务器刷新服务,从服务器就会同步[root@sb slaves]# ls10.0.1.zone sw.com.zone[root@sb slaves]# pwd/var/named/slaves
5.主从同步下图为本次我用wireshark抓包同步的过程
dns客户端
修改默认dns服务器地址
[root@localhost ~]# vim /etc/resolv.conf[root@localhost ~]# cat /etc/resolv.confnameserver 10.0.1.8
测试#正向解析
[root@rhel6 ~]# nslookup www.sw.comServer: 10.0.1.8Address: 10.0.1.8#53Name: www.sw.comAddress: 10.0.1.8
#逆向解析
[root@rhel6 ~]# nslookup 10.0.1.18Server: 10.0.1.8Address: 10.0.1.8#5318.1.0.10.in-addr.arpa name = sb.sw.com.
#使用dns从服务器正向解析
[root@rhel6 ~]# nslookup rhel6.sw.com 10.0.1.18Server: 10.0.1.18Address: 10.0.1.18#53Name: rhel6.sw.comAddress: 10.0.1.8
#解析网络域名
[root@localhost ~]# nslookup www.baidu.comServer: 10.0.1.8Address: 10.0.1.8#53Non-authoritative answer:www.baidu.com canonical name = www.a.shifen.com.Name: www.a.shifen.comAddress: 115.239.210.27Name: www.a.shifen.comAddress: 115.239.210.26