DNS 主服务器的配置

以前在做实验的过程中总结和写的一些教程的一些资料,一直没时间发布到博客上面,五一到了,终于有点时间发布啦!关于Linux上面还会有RHCE系列的学习笔记发表


1、 安装软件包: 
[root@master ~]# mount /dev/cdrom /media/cdrom/ 
mount: block device /dev/cdrom is write-protected, mounting read-only 
[root@master ~]# cd /media/cdrom/RedHat/RPMS/ 
[root@master RPMS]# rpm -ivh bin 
bind-9.2.4-2.i386.rpm                 bind-libs-9.2.4-2.i386.rpm 
bind-chroot-9.2.4-2.i386.rpm          bind-utils-9.2.4-2.i386.rpm 
bind-devel-9.2.4-2.i386.rpm           binutils-2.15.92.0.2-10.EL4.i386.rpm 
[root@master RPMS]# rpm -ivh bind-9.2.4-2.i386.rpm 
warning: bind-9.2.4-2.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e 
Preparing...                ########################################### [100%] 
   1:bind                   ########################################### [100%] 
[root@master RPMS]# rpm -qa |grep bind 
bind-libs-9.2.4-2 
ypbind-1.17.2-3 
bind-utils-9.2.4-2 
bind-9.2.4-2 
2、 安装缓存软件包: 
[root@master RPMS]# rpm -ivh caching-nameserver-7.3-3.noarch.rpm 
warning: caching-nameserver-7.3-3.noarch.rpm: V3 DSA signature: NOKEY, key ID 
db42a60e 
Preparing...                ########################################### [100%] 
   1:caching-nameserver     warning: /etc/named.conf saved as /etc/named.conf.rpmorig 
########################################### [100%] 
3、 配置主配置文件: 
[root@master RPMS]# vi /etc/named.conf 
zone "sina.com." IN { 
        type master; 
        file "sina.com.zone"; 
}; 
zone "16.16.172.in-addr.arpa" IN { 
        type master; 
        file "172.16.16.zone"; 
 
 
}; 
4、 检查配置格式是否正确: 
[root@master RPMS]# named-checkconf 
5、 配置正向区域文件: 
[root@master RPMS]# cd /var/named/ 
[root@master named]# vi sina.com.zone 
$TTL 86400 
www.wqmsl.cn@ IN  SOA  master.sina.com. root.sina.com. ( 
                                   42 
                                   3H 
                                   15M 
                                   1W 
                                   1D ) 
@      IN  NS  master.sina.com. 
master IN  A   172.16.16.10 
slave  IN  A   172.16.16.20 
client IN  A   172.16.16.30 
mail   IN CNAME master.sina.com. 
6、 检查区域文件是否正确: 
[root@master named]# named-checkzone sina.com. /var/named/sina.com.zone 
zone sina.com/IN: loaded serial 42 
OK 
7、 配置反向区域文件: 
[root@master named]# cp sina.com.zone 172.16.16.zone 
[root@master named]# vi 172.16.16.zone 
[root@master named]# cat 172.16.16.zone 
$TTL 86400 
@ IN  SOA  master.sina.com. root.sina.com. ( 
                                   42 
                                   3H 
                                   15M 
                                   1W 
                                   1D ) 
@      IN  NS  master.sina.com. 
10     IN  PTR  master.sina.com. 
20     IN  PTR  slave.sina.com. 
30     IN  PTR  client.sina.com. 
8、检查区域文件是否正确: 
[root@master named]# named-checkzone 16.16.172.in-addr-arpa /var/named/172.16.16.zone 
zone 16.16.172.in-addr-arpa/IN: loaded serial 42 
OK 
8、 启动服务 
[root@master named]# service named restart 
Stopping named:                                            [  OK  ] 
Starting named:                                            [  OK  ] 
从 DNS 服务器的配置 
1、 安装软件包 
[root@slave ~]# mount /dev/cdrom /media/cdrom/ 
mount: block device /dev/cdrom is write-protected, mounting read-only 
[root@slave ~]# cd /media/cdrom/RedHat/RPMS/ [root@slave RPMS]# rpm -ivh bind-9.2.4-2.i386.rpm caching-nameserver-7.3-3.noarch.rpm 
warning: bind-9.2.4-2.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e 
Preparing...                ########################################### [100%] 
   1:bind                   ########################################### [ 50%] 
   2:caching-nameserver     ########################################### [100%] 
[root@slave RPMS]# rpm -qa|grep bind 
bind-libs-9.2.4-2 
ypbind-1.17.2-3 
bind-utils-9.2.4-2 
bind-9.2.4-2 
2、 更改主配置文件 
[root@slave slaves]# vi /etc/named.conf 
zone "sina.com." IN { 
           type slave; 
           file "slaves/sina.com.zone"; 
           masters {172.16.16.10;}; 
}; 
zone "16.16.172.in-addr.arpa"  IN { 
           type slave; 
           file "slaves/172.16.16.ip-addr.arpa"; 
           masters {172.16.16.10;}; 
}; 
3、 启动服务 
[root@slave slaves]# service named restart 
Stopping named:                                            [  OK  ] 
Starting named:                                            [  OK  ] 
4、 查看区域文件是否复制过来 
[root@slave slaves]# cd /var/named/slaves/ 
[root@slave slaves]# ls -l 
total 16 
-rw-------  1 named named 391 Jun   8 16:50 172.16.16.ip-addr.arpa 
-rw-------  1 named named 379 Jun  8 16:41 sina.com.zone 
客户端验证工具 
[root@client ~]# nslookup 
> 172.16.16.10 
Server:         172.16.16.10 
Address:        172.16.16.10#53 
 
10.16.16.172.in-addr.arpa       name = master.sina.com. 
> master.sina.com 
Server:         172.16.16.10 
Address:        172.16.16.10#53 
 Name:   master.sina.com 
Address: 172.16.16.10 
> 172.16.16.20 
Server:         172.16.16.10 
Address:        172.16.16.10#53 
 
20.16.16.172.in-addr.arpa       name = slave.sina.com. 
> 172.16.16.20 
Server:         172.16.16.10 
Address:        172.16.16.10#53 
 
20.16.16.172.in-addr.arpa       name = slave.sina.com. 
> mail.sina.com 
Server:         172.16.16.10 
Address:        172.16.16.10#53 
 
mail.sina.com   canonical name = master.sina.com. 
Name:   master.sina.com 
Address: 172.16.16.10 
> 172.16.16.10 
Server:         172.16.16.10 
Address:        172.16.16.10#53 
 
10.16.16.172.in-addr.arpa       name = master.sina.com. 
>exit 
[root@client ~]# dig @172.16.16.10  slave.sina.com 
 
; <<>> DiG 9.2.4 <<>> @172.16.16.10 slave.sina.com 
;; global options:  printcmd 
;; Got answer: 
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7665 
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1 
 
;; QUESTION SECTION: 
;slave.sina.com.                        IN      A 
 
;; ANSWER SECTION: 
slave.sina.com.         86400   IN      A       172.16.16.20 
 
;; AUTHORITY SECTION: 
sina.com.               86400   IN      NS      master.sina.com. 
 
;; ADDITIONAL SECTION: 
master.sina.com.        86400   IN      A       172.16.16.10  
;; Query time: 86 msec 
;; SERVER: 172.16.16.10#53(172.16.16.10) 
;; WHEN: Mon Jun  8 16:55:49 2009 
;; MSG SIZE  rcvd: 85 
[root@client ~]# host mail.sina.com 
mail.sina.com is an alias for master.sina.com. 
master.sina.com has address 172.16.16.10

 

有什么问题 大家留言 一起研究,一起进步

QQ:459176770