DNS服務

實驗一:搭建DNS服務器

tarena.com

www.tarena.com192.168.10.11

bbs.tarena.com192.168.10.12

  blogbbs別名

1、 安裝軟件包

yum  配置完成

[root@localhost ~]# rpm -q bind bind-chroot caching-nameserver

package bind is not installed

package bind-chroot is not installed

package caching-nameserver is not installed

[root@localhostServer]#yumy  install

bind-9.3.6-20.P1.el5_8.5.x86_64.

rpmbind-chroot-9.3.6-20.P1.el5_8.5.x86_64.rpm caching-nameserver-9.3.6-20.P1.el5_8.5.x86_64.rpm

2、 修改主配置文件

[root@localhost chroot]# cd /var/named/chroot/etc/

[root@localhost etc]# cp named.caching-nameserver.conf named.conf

[root@localhost etc]# vim named.conf

..

15         listen-on port 53 { 192.168.55.254; };

……

27         allow-query     { any; };

28         allow-query-cache { any; };

……

37         match-clients      { any; };

38         match-destinations { any; };

[root@localhost etc]# vim named.rfc1912.zones

……

zone "tarena.com" IN {                     //定義正向區域

        type master;

        file "tarena.com.zone";

};

zone "55.168.192.in-addr.arpa" IN {          //定義反向區域

        type master;

         file "tarena.com.arpa";

};

[root@localhost etc]# named-checkconf named.conf     //檢測語法  無輸出,無錯誤

3、 修改數據庫文件

[root@localhost named]# cp named.local tarena.com.zone

[root@localhost named]# cp named.local tarena.com.arpa

[root@localhost named]# vim tarena.com.zone

$TTL    86400

@       IN      SOA     localhost. root.localhost.  (

                                     1997022700 ; Serial

                                     28800      ; Refresh

                                     14400      ; Retry

                                     3600000    ; Expire

                                     86400 )    ; Minimum

       IN      NS      dns1.tarena.com.

dns1    IN      A      192.168.55.254

www   IN    A      192.168.55.253

bbs     IN      A      192.168.55.252

blog    IN     CNAME   bbs

[root@localhost named]# vim tarena.com.arpa

$TTL    86400

@       IN      SOA     localhost. root.localhost.  (

                                     1997022700 ; Serial

                                     28800      ; Refresh

                                     14400      ; Retry

                                     3600000    ; Expire

                                     86400 )    ; Minimum

       IN      NS     dhs1.tarena.com.

254     IN      PTR     dns1.tarena.com.

253     IN      PTR      www.tarena.com.

252     IN      PTR      bbs.tarena.com.

[root@localhostnamed]#named-checkzonetarena.com tarena.com.zone

zone tarena.com/IN: loaded serial 1997022700

OK

[root@localhostnamed]#named-checkzonetarena.com tarena.com.arpa

zone tarena.com/IN: loaded serial 1997022700

OK

4、 啓動服務

[root@localhost named]# service named restart

[root@localhost named]# chkconfig named on

5、 客戶機測試

nslookup

實驗二:

       訪問www.tarena.com時三分之二訪問的地址是192.168.55.254,三分之一訪問的是192.168.55.110,用戶只要輸入對的域名tarena.com就可以訪問,用戶只輸入域名tarena.com也可以訪問

1、 修改數據庫文件

[root@localhost etc]# cd /var/named/chroot/var/named/

[root@localhost named]# vim tarena.com.zone

       IN      NS     dns1.tarena.com.

dns1    IN      A       192.168.55.254

www   IN     A        192.168.55.253

www    IN     A        192.168.55.253

www    IN     A        192.168.55.110

bbs     IN     A        192.168.55.252

blog    IN   CNAME      bbs

tarena.com IN A         192.168.55.110

//只要輸對域名就可以訪問

*          IN   A        192.168.55.110

//只輸入域名也可以訪問

$GENERATE  20-50  station$ IN A 192.168.55.$

2、 在另一臺PC上安裝httpd

[root@localhostslaves]#scp192.168.55.254:/etc/yum.repos.d/server.repo /etc/yum.repos.d/                               //yum

[root@localhost slaves]# yum -y install httpd

[root@localhost slaves]# vim /var/www/html/index.html

<html>

<head><title>this is www.tarena.com</title>

</head>

<body>

<h1>www.tarena.com</h1>

<hr></hr>

cocour=pink

welcome

</body>

</html>

3、 啓動服務

[root@localhost slaves]# service httpd restart

[root@localhost named]# chkconfig  httpdon

[root@localhost named]# service named restart

[root@localhost named]# chkconfig named on

4、 客戶端測試

host

瀏覽器輸入tarena.com

實驗三:搭建從DNS服務器

      給上面的主DNS搭建一個輔助DNS

1、安裝軟件包

[root@localhost ~]# rpm -q bind bind-chroot caching-nameserver

package bind is not installed

package bind-chroot is not installed

package caching-nameserver is not installed

[root@localhost ~]# yum -y install bind bind-chroot caching- nameserver

2、修改從DNS的主配置文件

[root@localhost ~]# cd /var/named/chroot/etc/

[root@localhost etc]# cp -p named.caching-nameserver.conf  named.conf

[root@localhost etc]# vim named.conf

...

15         listen-on port 53 { 192.168.55.254; };

...

27         allow-query     { any; };

28         allow-query-cache { any; };

...

37         match-clients      { any; };

38         match-destinations { any; };

[root@ser2 etc]# vim named.rfc1912.zones

...

51 zone "tarena.com" IN {

52         type slave;

53         file "slaves/tarena.com.zone";

54         masters { 192.168.55.110; };

55 };

56

57 zone "10.168.192.in-addr.arpa" IN {

58         type slave;

59         file "slaves/tarena.com.arpa";

60         masters { 192.168.55.110; };

61 };

[root@ser2 etc]# named-checkconf named.conf

3、修改主DNS的主配置文件,添加授權信息

[root@localhost ~]# cd /var/named/chroot/etc/

[root@localhost etc]# vim named.conf    //添加21行內容

...

21         allow-transfer { 192.168.55.110; };

...

[root@localhost etc]# service named restart

4、啓動從DNS服務器並驗證

[root@localhost etc]# service named restart

[root@localhost etc]# chkconfig named on

[root@localhost etc]# ls /var/named/chroot/var/named/slaves/

tarena.com.zone tarena.com.arpa


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