1.dns快取記憶體服務搭建
伺服器:yum install bing.x86_64 安裝dns服務
這裡寫圖片描述
設定ip及其閘道器

     vim /etc/named.conf      配置dns服務檔案
           11  listen-on port 53 {any;};  開啟任意服務端網路介面dns埠
           17  allow-query  {any;};  允許所有主機訪問這臺dns伺服器
               forwarders {114.114.114.114;};
           33  dnssec-validation no    關閉網路認證

這裡寫圖片描述

       systemctl restart named  重啟dns服務
           vim /etc/resolv.conf   配置地址解析檔案
            nameserver 114.114.114.114  本機不知時訪問114.114.114.114

這裡寫圖片描述

  客戶機:vim /etc/resolv.conf   
             nameserver 172.25.254.107

這裡寫圖片描述

   dig www.baidu.com 查詢baidu的ip(第二次訪問時速度更快,因為訪問一次後,地址解析的檔案快取到本機上)

這裡寫圖片描述
2.dns的正向解析:(域名—>ip)

          vim /etc/named.conf
             刪除forwarders {114.114.114.114;};行
          cd /var/named/
          cp -p named.localhost westos.com.zone

這裡寫圖片描述

  vim westos.com.zone

這裡寫圖片描述

   vim /etc/named.rfc1912.zones
       zone "westos.com" IN {
           type master;
           file "westos.com.zone";
          allow-update { none; };
   };

這裡寫圖片描述

 dig hello.westos.com

這裡寫圖片描述
(3)迴圈輪叫:

  vim westos.com.zone

這裡寫圖片描述

     dig www.westos.com

這裡寫圖片描述
這裡寫圖片描述
3.dns反向解析(ip—–>域名):

   vim /etc/named.rfc1912.zones     
         zone "254.25.172.in-addr.arpa" IN {
             type master;
            file "westos.com.ptr";
            allow-update { none; };
       };

這裡寫圖片描述

   cd /var/named/
   cp -p named.loopback westos.com.ptr
   vim westos.com.ptr

這裡寫圖片描述

   systemctl restart named重啟dns服務
   dig -x 172.25.254.111(-x 反向解析)

這裡寫圖片描述
4.內外網的搭建(多向解析)

  cp -p /etc/named.rfc1912.zones  /etc/named.rfc1912.inter
   vim /etc/named.rfc1912.inter
     zone "westos.com" IN {
        type master;
        file "westos.com.inter";
        allow-update { none; };
     };

這裡寫圖片描述
這裡寫圖片描述

   cp -p westos.com.zone  westos.com.inter
   vim westos.com.inter

這裡寫圖片描述

  vim /etc/named.conf
    view  localnet {
        match-clients { 172.25.254.107; };
        zone "." IN{
                type hint;
                file "named.ca";
        };
        include "/etc/named.rfc1912.zones";
    };
    view  inter {
        match-clients { any; };
        zone "." IN{
                type hint;
                file "named.ca";
        };
          include "/etc/named.rfc1912.inter";
    };

這裡寫圖片描述

   systemctl restart named
   dig www.westos.com

這裡寫圖片描述
5.dns機群(輔助dns):
serve中: 安裝並設定dns的配置檔案與前面相同

    yum install bind
    systemctl restart firewalld
    vim /etc/named
           11  listen-on port 53 {any;};  開啟任意服務端網路介面dns
           17  allow-query  {any;};  允許所有主機訪問這臺dns伺服器
           33  dnssec-validation no    關閉網路認證
           systemctl restart named  重啟dns服務
   vim /etc/named.rfc1912.zones
       zone "westos.com" IN {
          type slave;                    輔助dns
          masters { 172.25.254.107; };  在172.25.254.107上下載westos.com.zone檔案到slaves中
          file "slaves/westos.com.zone";
          allow-update { none; };
       };

這裡寫圖片描述

    vim /etc/resolv.conf
      nameserver 172.25.254.107

desktop中:

    vim /etc/named.rfc1912.zones
       zone "westos.com" IN {
          type master;
          file "westos.com.zone";
          allow-update { none; };
          also-notify { 172.25.254.207; };    同步到的主機ip,可多個,中間用空格間隔
      };

這裡寫圖片描述

    vim /var/name/westos.com.zone

這裡寫圖片描述

dig www.westos.com

這裡寫圖片描述
6.dns 更新
實驗前備份/var/named/westos.com.zone
selinux為disabled
這裡寫圖片描述
dns伺服器:

   vim /etc/named.rfc1912.zones
       zone "westos.com" IN {
          type master;
          file "westos.com.zone";
          allow-update { 172.25.254.7; };  允許更新的主機ip
          also-notify { 172.25.254.207; };
       };

這裡寫圖片描述

   systemctl restart named
   chmod 770 /var/named/  許可權

可更新的主機:

      nsupdate  新增更新
       >server 172.25.254.107
       >update add test.westos.com 86400 A 172.25.254.119 
       >send

這裡寫圖片描述

 vim /var/named/westos.com.zone

這裡寫圖片描述

        nsupdate 刪除更新
         >server 172.25.254.107
         >update delete test.westos.com 
         >send

這裡寫圖片描述
7.key方式解析:

     dnssec-keygen -a HMAC-MD5 -b 128 -n HOST westos
     cat Kwestos.+157+14628.private
     cat Kwestos.+157+14628.key

這裡寫圖片描述

   cp /etc/rndc.key  /etc/westos.key -p
     systemctl restart named

這裡寫圖片描述

    vim /etc/westos.key
        key "westos" {
          algorithm hmac-md5;
          secret "aclcI8b+xmJOpOhrpDsE7Q==";
      };

這裡寫圖片描述

   vim /etc/named.conf
     include "/etc/westos.key";

這裡寫圖片描述

     vim /etc/named.rfc1912.zone
         zone "westos.com" IN {
          type master;
          file "westos.com.zone";
          allow-update { key westos; };
          also-notify { 172.25.254.207; };
       };

這裡寫圖片描述

     systemctl restart named
     scp Kwestos.+157+14628.* root@172.25.254.7:/mnt/

這裡寫圖片描述

       dig www.westos.com

這裡寫圖片描述
8.動態域名解析(花生殼):
安裝dhcpd

     vim /etc/dhcp/dhcpd.conf
     cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf 
     systemctl restart named
     systemctl restart dhcpd
     vim /etc/dhcp/dhcpd.conf
       option domain-name "westos.com";
option domain-name-servers 172.25.254.107;

default-lease-time 600;
max-lease-time 7200;
ddns-update-style interim; 開啟dhcp動態域名更新服務
log-facility local7;

   subnet 172.25.254.0 netmask 255.255.255.0 {
       range 172.25.254.215  172.25.254.220;
       option routers 172.25.254.107;
      }
   key westos{
            algorithm hmac-md5;
            secret aclcI8b+xmJOpOhrpDsE7Q==;
     };
      zone westos.com. {
          primary 127.0.0.1;
          key westos;
     }
    systemctl restart dhcpd

這裡寫圖片描述
server虛擬機器中:

      hostnamectl set-hostname linux.westos.com
      systemctl restart network

這裡寫圖片描述

      dig linux.westos.com

這裡寫圖片描述
重新整理後server重新獲得ip地址,dig linux.westos.com,檢視地址是不是會更新
這裡寫圖片描述