中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

DNS查詢過程及DNS服務器簡單搭建

發布時間:2020-07-12 21:12:46 來源:網絡 閱讀:1059 作者:春天的金縷 欄目:建站服務器

1、描述DNS查詢過程以及DNS服務器類別。

    DNS查詢過程:

    一次完整的查詢請求經過的流程:

    Client--> hosts文件 --> DNS Local Cache --> DNS Server (recursion) -->

         自己負責解析的域:直接查詢數據庫并返回答案;

         不是自己負責解析域:ServerCache --> iteration(迭代)

    DNS服務器類別:

         -DNS服務器:

         DNS服務器:維護所負責解析的域數據庫的那臺服務器;讀寫操作均可進行;

         DNS服務器:從主DNS服務器那里或其它的從DNS服務器那里“復制”一份解析庫;但只能進行讀操作;

             “復制”操作的實施方式:

               序列號:serial, 也即是數據庫的版本號;主服務器數據庫內容發生變化時,其版本號遞增;

               刷新時間間隔:refresh,從服務器每多久到主服務器檢查序列號更新狀況;

               重試時間間隔:retry,從服務器從主服務器請求同步解析庫失敗時,再次發起嘗試請求的時間間隔;

               過期時長:expire,從服務器始終聯系不到主服務器時,多久之后放棄從主服務器同步數據;停止提供服務;

               否定答案的緩存時長:

2、搭建一套DNS服務器,負責解析magedu.com域名(自行設定主機名及IP

  (1)、能夠對一些主機名進行正向解析和逆向解析;

  (2)、對子域cdn.magedu.com進行子域授權,子域負責解析對應子域中的主機名;

  (3)、為了保證DNS服務系統的高可用性,請設計一套方案,并寫出詳細的實施過程

 

         首先安裝配置bind:

                   yuminstall bind -y

                   servicenamed start 

                            systemctlstart  named.servicecentos7)

                   ss-tunl |grep 53

         bind

                            主配置文件:/etc/named.conf

                                     或包含進來其它文件;

                                               /etc/named.iscdlv.key

                                               /etc/named.rfc1912.zones

                                               /etc/named.root.key

                            析庫文件:

                                     /var/named/目錄下;

                                               一般名字為:ZONE_NAME.zone

                                              

               注意:(1) 一臺DNS服務器可同時為多個區域提供解析;

                     (2) 必須要有根區域解析庫文件:named.ca

                     (3) 還應該有兩個區域解析庫文件:localhost127.0.0.1的正反向解析庫;

                              正向:named.localhost

                              反向:named.loopback

A.解析一個正向區域

         1.緩存名稱服務器的配置:

         [root@localhost~]# vim /etc/named.conf

 

         //

         //named.conf

         //

         //Provided by Red Hat bind package to configure the ISC BIND named(8) DNS

         //server as a caching only nameserver (as a localhost DNS resolver only).

         //

         //See /usr/share/doc/bind*/sample/ for example named configuration files.

         //

         //See the BIND Administrator's Reference Manual (ARM) for details about the

         //configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html

 

         options{

         //               listen-on port 53 { 127.0.0.1; };                 ###注銷本行,注銷本行,表示監聽所有地址

         //               listen-on-v6 port 53 { ::1; };                         ###注銷本行

                            directory       "/var/named";

                            dump-file      "/var/named/data/cache_dump.db";

                            statistics-file"/var/named/data/named_stats.txt";

                            memstatistics-file"/var/named/data/named_mem_stats.txt";

         //               allow-query     { localhost; };         ###關閉僅允許本地查詢

    

   recursion yes;

 

   // dnssec-enable yes;                         ###學習時,建議關閉dnssecDNS安全認證

   // dnssec-validation yes;                     ###學習時,建議關閉dnssec

      修改完成后檢查配置文件的語法錯誤

          named-checkconf   [/etc/named.conf]

         [root@localhost~]# named-checkconf           

         2.定義區域

         在主配置文件中或主配置文件輔助配置文件中實現

         [root@localhost~]# vim /etc/named.rfc1912.zones   ###編輯配置文件,添加以下內容

         zone"magedu.com" IN {                                                                     ###添加

       type master;

       file "magedu.com.zone";

         };

         3.建立區域數據文件(主要記錄為AAAAA記錄)

              /var/named目錄下建立區域數據文件;

[root@localhostnamed]# vim /var/named/magedu.com.zone

$TTL86400                                          ###緩存有效期86400=1

                   $ORIGINmagedu.com.                                                                   

                   @       IN     SOA     ns1.magedu.com.dnsadmin.magedu.com. (

                                     2017060601     ###序列號

                                     1H             ###刷新時間

                                     10M            ###重試時間

                                     3D             ###過期時間

                                     1D)            ###否定答案時間

                                     IN      NS     ns1

                                     IN      NS     ns2

                                     IN      MX 10  mx1

                                     IN      MX 20  mx2

                   ns1     IN     A       192.168.0.104

                   ns2     IN     A       192.168.0.105

                   mx1     IN     A       192.168.0.106

                   mx2     IN     A       192.168.0.107

                   www     IN      A      192.168.0.104

                   web     IN     CNAME   www

~    語法檢查:

                   [root@localhostnamed]# named-checkconf

                   [root@localhostnamed]# named-checkzone magedu.com /var/named/magedu.com.zone

                   zonemagedu.com/IN: loaded serial 2017060601

                   OK

           權限修改:

                   [root@localhostnamed]# chown :named /var/named/magedu.com.zone    ###修改屬組為named

                   chmodo= /var/named/magedu.com.zone                                                               ###修改其他無權限

         4.讓服務器重載配置文件和區域數據文件

                   #rndc  reload

                   #systemctl  reload  named.service

         測試:

                   dig-t A www.magedu.com @192.168.0.104

                  

同理,配置解析一個反向區域

         1.定義區域

                   在主配置文件中或主配置文件輔助配置文件中實現;

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

                   zone"0.168.192.in-addr.arpa" IN {

                            typemaster;

                            file"192.168.0.zone";

                   };

         2.定義區域解析庫文件(主要記錄為PTR

                   [root@localhostnamed]# vim /var/named/192.168.0.zone

                   $TTL86400

                   $ORIGIN0.168.192.in-addr.arpa.

                   @       IN     SOA     ns1.magedu.com.nsadmin.magedu.com (

                                                        2017060601

                                                        1H

                                                        10M

                                                        3D

                                                        1D)

                                     IN      NS     ns1.magedu.com.

                   104     IN     PTR     ns1.magedu.com.

                   105     IN     PTR     ns2.magedu.com.

                   106     IN     PTR     mx1.magedu.com.

                   107     IN     PTR     mx2.magedu.com.

                   104     IN     PTR     www.magedu.com.

 

                   權限修改:    

                   [root@localhostnamed]# chgrp named /var/named/192.168.0.zone

                   [root@localhostnamed]# chmod o= /var/named/192.168.0.zone

                   語法檢查:

                   [root@localhostnamed]# named-checkconf

                   [root@localhostnamed]# named-checkzone 0.168.192.in-addr.arpa /var/named/192.168.0.zone

                   zone0.168.192.in-addr.arpa/IN: loaded serial 2017060601

                   OK

        

                   #rndc  reload

                   #systemctl  reload  named.service

         3.讓服務器重載配置文件和區域數據文件

                   #rndc  reload

                   #systemctl  reload  named.service

         測試;

         dig-x 192.168.0.104 @192.168.0.104

        

B.子域授權

         1.magedu.com解析庫添加子域。

                   [root@localhost~]# vim /var/named/magedu.com.zone

                   $TTL86400

                   $ORIGINmagedu.com.

                   @       IN     SOA     ns1.magedu.com.dnsadmin.magedu.com. (

                                     2017060612

                                     1H

                                     10M

                                     3D

                                     1D)

                                     IN      NS     ns1

                                     IN      NS     ns2

                                     IN      MX 10  mx1

                                     IN      MX 20  mx2

                   ns1     IN     A       192.168.0.104

                   ns2     IN     A       192.168.0.150

                   mx1     IN     A       192.168.0.106

                   mx2     IN     A       192.168.0.107

                   www     IN     A       192.168.0.104

                   web     IN     CNAME   www

                   pop3    IN     A       192.168.0.108

                   cdn     IN     NS      ns1.cdn                                                   ###添加子域

                   cdn     IN     NS      ns2.cdn                                                   ###添加子域

                   ns1.cdnIN      A       192.168.0.103                                ###添加A記錄

                   ns2.cdnIN      A       192.168.0.155                                ###添加A記錄

         2.對子域服務器安裝bind并改配置文件及添加解析庫。

                   [root@localhost~]# yum install bind -y                              ###子域服務器安裝

                   [root@localhost~]# vim /etc/named.conf

                   //Provided by Red Hat bind package to configure the ISC BIND named(8) DNS

                   //server as a caching only nameserver (as a localhost DNS resolver only).

                   //

                   //See /usr/share/doc/bind*/sample/ for example named configuration files.

                   //

 

                   options{

                                     listen-onport 53 { 127.0.0.1; 192.168.0.103; };      ###添加與外部通信主機地址

                                     listen-on-v6port 53 { ::1; };

                                     directory       "/var/named";

                                     dump-file       "/var/named/data/cache_dump.db";

                                     statistics-file"/var/named/data/named_stats.txt";

                                     memstatistics-file"/var/named/data/named_mem_stats.txt";

                   //               allow-query     { localhost; };                                                      ###關閉僅允許本地查詢

                                     recursionyes;

 

                                     dnssec-enableno;             ###改為no

                                     dnssec-validationno;       ###改為no

                                     .......

                   [root@localhost~]# service named start

                   Generating/etc/rndc.key:                                 [確定]

                   啟動 named   

                   [root@localhost~]# vim /etc/named.rfc1912.zones                       ###編輯配置文件添加解析庫

                   zone"cdn.magedu.com" IN {

       type master;

       file "cdn.magedu.com.zone";

                   };

       [root@localhost ~]# vim /var/named/cdn.magedu.com.zone                 ###編輯解析庫數據

                   $TTL3600

                   $ORIGINcdn.magedu.com.

                   @       IN     SOA     ns1.cdn.magedu.com.     nsadmin.cdn.magedu.com. (

                                                        2017060601

                                                        1H

                                                        10M

                                                        1D

                                                        2H)

                                     IN      NS     ns1

                   ns1     IN     A       192.168.0.103

                   www     IN     A       192.168.0.10                  

                   [root@localhost~]# chgrp named /var/named/cdn.magedu.com.zone ###修改屬組為named

                   [root@localhost~]# chmod o= /var/named/cdn.magedu.com.zone          ###修改其他無權限

                   [root@localhost~]# rndc reload

                   serverreload successful

                   測試使用dig

                   [root@localhost~]# dig -t A www.cdn.magedu.com @192.168.0.103

                   定義轉發

                   [root@localhost~]# vim /etc/named.rfc1912.zones                                  ###編輯配置文件增加區域轉發

                   zone"magedu.com" IN {

       type forward;                                                                                                                  ###定義轉發

       forward only;                                                                                                                   ###只轉發                                                                                                             

       forwarders { 192.168.0.104; 192.168.0.150; };

                   };

                   [root@localhost~]# named-checkconf                                                                    ###檢查

                   [root@localhost~]# rndc reload                                                                                ###重載

                   [root@localhost~]# dig -t A www,magedu.com @192.168.0.103                   ###測試子域解析父域

                  

                   ;<<>> DiG 9.8.2rc1-RedHat-9.8.2-0.62.rc1.el6_9.2 <<>> -tA www.magedu.com @192.168.0.103

                   ;;global options: +cmd

                   ;;Got answer:

                   ;;->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56294

                   ;;flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

 

                   ;;QUESTION SECTION:

                   ;www.magedu.com.                           IN     A

 

                   ;;ANSWER SECTION:

                   www.magedu.com.                   86400       IN     A       192.168.0.110

 

                   ;;AUTHORITY SECTION:

                   magedu.com.           86400       IN     NS    ns1.magedu.com.

                   magedu.com.           86400       IN     NS    ns2.magedu.com.

 

                   ;;ADDITIONAL SECTION:

                   ns1.magedu.com.             86400       IN     A       192.168.0.104

                   ns2.magedu.com.             86400       IN     A       192.168.0.150

 

                   ;;Query time: 4 msec

                   ;;SERVER: 192.168.0.103#53(192.168.0.103)

                   ;;WHEN: Thu Jun  8 20:50:31 2017

                   ;;MSG SIZE  rcvd: 116

C.全局轉發:針對凡本地沒有通過zone定義的區域查詢請求,通通轉給某轉發器;

                                     options{

                                               ......

                                               forward  {only|first};

                                               forwarders  { SERVER_IP; };

                                               .....

                                      };

主從同步:

         從服務器配置與主服務器配置安裝相同:

         1.[root@localhost~]# yum install bind -y                 ###安裝

         2.編輯/etc/named.conf文件,與前面安裝一致

         3.[root@localhost~]# vim /etc/named.rfc1912.zones          ###編輯添加從服務

           zone "0.168.192.in-addr.arpa" IN {

       type slave;                                                                                            ###類型為從服務器

       file "slaves/192.168.0.zone";

       masters { 192.168.0.104; };                                                   ###主服務器地址

                   };

         4.在主服務器解析文件/var/named/magedu.zone中新增NS NS記錄有個A地址為從服務器地址。

         主服務器 rndcreload

         5.從服務器檢查配置文件并重啟服務  systemctl restartnamed.service

         6.服務啟動后,會在/var/named/slaves/自動添加magedu.com.zone文件

         主從配置完成

         注意:時間需同步   ntpdate命令


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

嘉义市| 云安县| 海宁市| 布尔津县| 册亨县| 台州市| 土默特右旗| 普陀区| 历史| 尼木县| 大余县| 法库县| 永德县| 铜山县| 益阳市| 金阳县| 石家庄市| 哈尔滨市| 谷城县| 田阳县| 遵义市| 丹凤县| 曲麻莱县| 阳泉市| 景谷| 青海省| 莲花县| 襄垣县| 姚安县| 开江县| 彭泽县| 辽宁省| 青冈县| 区。| 乌鲁木齐市| 中卫市| 伊川县| 黄石市| 莒南县| 夏河县| 建德市|