DNS配置筆記

[root@ypser ~]# rpm -qa |grep bind                  //查看Bind是否安裝
bind-utils-9.3.4-10.P1.el5
bind-9.3.4-10.P1.el5
bind-libs-9.3.4-10.P1.el5
ypbind-1.19-11.el5
bind-chroot-9.3.4-10.P1.el5
[root@ypser ~]#
[root@ypser ~]# rpm -qa|grep caching-nameserver    //
查看caching-nameserver是否安裝
caching-nameserver-9.3.4-10.P1.el5
[root@ypser ~]#
[root@ypser ~]# rpm -ql caching-nameserver      //查看caching-nameserver所有安裝文件
/etc/named.caching-nameserver.conf

/etc/named.conf
/etc/named.rfc1912.zones

/usr/share/doc/caching-nameserver-9.3.4
/usr/share/doc/caching-nameserver-9.3.4/Copyright
/usr/share/doc/caching-nameserver-9.3.4/rfc1912.txt
/var/named/chroot/etc/named.caching-nameserver.conf
/var/named/chroot/etc/named.conf
/var/named/chroot/etc/named.rfc1912.zones
/var/named/chroot/var/named/localdomain.zone
/var/named/chroot/var/named/localhost.zone
/var/named/chroot/var/named/named.broadcast
/var/named/chroot/var/named/named.ca
[root@ypser ~]# vi /etc/named.rfc1912.zones    //RedHat 5Fedora 5以上的版本named..conf被分爲named.caching-nameserver.conf named.rfc1912.zones

 

 

 

options {
          dirctory  "/var/named";
};
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "." IN {
        type hint;
        file "named.ca";                 //刪除其他不要的文件只保留三個文件並修改
};

 

 

zone "test.net" IN {
        type master;
        file "test.net.zone";
        allow-update { none; };
};

 

zone "0.168.192.in-addr.arpa" IN {
        type master;
        file "test.net.rev";
        allow-update { none; };
};

 

[root@ypser ~]# cd /var/named/chroot//var/named/
[root@ypser named]# pwd
/var/named/chroot/var/named
[root@ypser named]# ll
drwxrwx--- 2 named named 1024 06-12 12:03 data
-rw-r----- 1 root  named  198 2009-01-21 localdomain.zone
-rw-r----- 1 root  named  195 2009-01-21 localhost.zone
-rw-r----- 1 root  named  427 2009-01-21 named.broadcast
-rw-r----- 1 root  named 1892 2009-01-21 named.ca
-rw-r----- 1 root  named  424 2009-01-21 named.ip6.local
-rw-r----- 1 root  named  426 2009-01-21 named.local
-rw-r----- 1 root  named  427 2009-01-21 named.zero
drwxrwx--- 2 named named 1024 2004-07-27 slaves
[root@ypser named]#
[root@ypser named]#cp –p localhost.zone test.net.zone    //創建正向域文件
[root@ypser named]#cp –p named.local test.net.rev      //創建反向域文件
[root@ypser named]# vi test.net.zone 
$TTL    86400
@               IN SOA  dns.tset.net.       root.test.net. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum

 

                IN NS           dns.test.net.
                IN MX 5        mail.test.net.
dns             IN A            192.168.0.99
mail            IN A            192.168.0.100
www             IN A            192.168.0.100
[root@ypser named]#
[root@ypser named]#
[root@ypser named]# vi test.net.rev
$TTL    86400
@       IN      SOA     dns.test.net. root.test.net.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN      NS      dns.test.net.
99       IN      PTR     dns.test.net.
100       IN      PTR     mail.test.net.
100      IN      PTR     www.test.net.
[root@ypser named]#
[root@ypser ~]# ln -s /var/named/chroot//var/named/test.net.zone  /var/named/test.net.zone
[root@ypser ~]# ln -s /var/named/chroot//var/named/test.net.rev  /var/named/test.net.rev
[root@ypser ~]# service named restart
停止 named[確定]
啓動 named
named配置錯誤::
/etc/named.rfc1912.zones:10: unknown option 'options'
[失敗]

 

[root@ypser ~]# vi /etc/named.rfc1912.zones        //冒號+10找到錯誤並修正

 

options {
          dirctory  "/var/named";
};
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "." IN {
        type hint;
        file "named.ca";
};

 

 

zone "test.net" IN {
        type master;
        file "test.net.zone";
        allow-update { none; };
};

 

zone "0.168.192.in-addr.arpa" IN {
        type master;
        file "test.net.rev";
        allow-update { none; };
};

 

~
~
~
~
~
~
~
~
~
"/etc/named.rfc1912.zones" 27L, 520C written
[root@ypser ~]# service named restart
停止 named[確定]
啓動 named[確定]

 

[root@ypser ~]# nslookup
> service 192.168.0.99     
;; connection timed out; no servers could be reached    //命令錯誤應爲 server192.168.0.99修改服務器地址
[root@ypser ~]# rndc reload
server reload successful
[root@ypser ~]#
[root@ypser ~]# netstat -an |grep 53            //檢查DNS服務是否正常
tcp        0      0 127.0.0.1:53                0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:953               0.0.0.0:*                   LISTEN     
tcp        0      0 ::1:53                      :::*                        LISTEN     
tcp        0      0 ::1:953                     :::*                        LISTEN     
udp        0      0 127.0.0.1:53                0.0.0.0:*                              
udp        0      0 192.168.0.99:49614          202.96.128.86:53            ESTABLISHED
udp        0      0 0.0.0.0:5353                0.0.0.0:*                              
udp        0      0 ::1:53                      :::*                                   
udp        0      0 :::5353                     :::*                                   
unix  3      [ ]         STREAM     CONNECTED     10539  /var/run/acpid.socket

 

[root@ypser ~]# ping dns.test.net
PING dns.test.net (192.168.0.99) 56(84) bytes of data.
64 bytes from dns.test.net (192.168.0.99): icmp_seq=1 ttl=64 time=0.026 ms
64 bytes from dns.test.net (192.168.0.99): icmp_seq=2 ttl=64 time=0.037 ms
64 bytes from dns.test.net (192.168.0.99): icmp_seq=3 ttl=64 time=0.026 ms
64 bytes from dns.test.net (192.168.0.99): icmp_seq=4 ttl=64 time=0.315 ms
64 bytes from dns.test.net (192.168.0.99): icmp_seq=5 ttl=64 time=0.025 ms

 

--- dns.test.net ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
rtt min/avg/max/mdev = 0.025/0.085/0.315/0.115 ms
[root@ypser ~]#
[root@ypser ~]# nslookup
> www.test.net
Server:         127.0.0.1
Address:        127.0.0.1#53

 

Name:   www.test.net
Address: 192.168.0.100
> dns.test.net
Server:         127.0.0.1
Address:        127.0.0.1#53

 

Name:   dns.test.net
Address: 192.168.0.99
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章