DNS域名解析服務(二)

一、構建緩存域名服務器

[root@localhost ~]# vi /etc/named.conf
"/etc/named.conf" 18L, 430Clinux

options {緩存

       listen-on port 53 { 192.168.66.13; };服務器

  directory"/var/named";dom

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

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

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

  recursing-file "/var/named/data/named.recursing";ip

  secroots-file "/var/named/data/named.secroots";域名

  allow-query { any; };it

  recursion yes;

};
zone "." IN {

  type hint;

  file "named.ca";
};


~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ :wq "/etc/named.conf" 18L, 430C written 

二、構建主從域名服務器

全部服務器:
iptables -F
systemctl stop firewalld
setenforce 0

配置yum


主服務器:
[root@localhost ~]# yum -y install bind
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.200.111
nameserver 192.168.200.112
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.111 ns1.crushlinux.com
192.168.200.112 ns2.crushlinux.com

[root@localhost ~]# cat /etc/named.conf
options {
directory "/var/named";
};

zone "crushlinux.com" IN {
type master;
file "crushlinux.zheng";
allow-transfer { 192.168.200.112; };
};

zone "200.168.192.in-addr.arpa" IN {
type master;
file "crushlinux.fan";
allow-transfer { 192.168.200.112; };
};
[root@localhost ~]#
[root@localhost ~]# cat /var/named/crushlinux.zheng
$TTL 86400
@   IN   SOA   crushlinux.com.   admin.crushlinux.com. (
      20190817
        3H
       15M  
       1W
       1D
)
   IN   NS      ns1.crushlinux.com.
     IN   NS            ns2.crushlinux.com.
     IN   MX 10    mail.crushlinux.com.
ns1  IN   A         192.168.200.111
ns2  IN   A       192.168.200.112
mail  IN     A       192.168.200.113
www  IN    A       192.168.200.114
study  IN   A       192.168.200.115
*    IN   A       192.168.200.111
ftp   IN  CNAME     www

[root@localhost ~]# cat /var/named/crushlinux.fan
$TTL 86400        管理員郵箱
@   IN   SOA   crushlinux.com.   admin.crushlinux.com. (
      20190817
        3H
            15M
       1W
       1D
)
   IN   NS     ns1.crushlinux.com.
   IN   NS     ns2.crushlinux.com.
   IN   MX 10   mail.crushlinux.com.
111   IN   PTR   ns1.crushlinux.com.
112   IN   PTR   ns2.crushlinux.com.
113   IN   PTR   mail.crushlinux.com.
114   IN   PTR   www.crushlinux.com.
115   IN   PTR   study.crushlinux.com.
111   IN   PTR   ns1.crushlinux.com.
[root@localhost ~]# chown :named /var/named/crushlinux.*
[root@localhost ~]# named-checkconf -z /etc/named.conf
[root@localhost ~]# named-checkzone crushlinux.com /var/named/crushlinux.zheng
[root@localhost ~]# named-checkzone crushlinux.com /var/named/crushlinux.fan
[root@localhost ~]# systemctl restart named

===============================================================================
從服務器:
[root@localhost ~]# yum -y install bind
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.200.111
nameserver 192.168.200.112
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.111 ns1.crushlinux.com
192.168.200.112 ns2.crushlinux.com


[root@localhost ~]# cat /etc/named.conf
options {
directory "/var/named";
};

zone "crushlinux.com" IN {
type slave;
file "slaves/crushlinux.zheng";
masters { 192.168.200.111; };
};
zone "200.168.192.in-addr.arpa" IN {
type slave;
file "slaves/crushlinux.fan";
masters { 192.168.200.111; };
};

[root@localhost ~]# systemctl restart named

=======================================================

注意:

/etc/resolv.conf它是DNS客戶機配置文件,用於設置DNS服務器的IP地址及DNS域名,還包含了主機的域名搜索順序。該文件是由域名解析 器(resolver,一個根據主機名解析IP地址的庫)使用的配置文件。它的格式很簡單,每行以一個關鍵字開頭,後接一個或多個由空格隔開的參數。

resolv.conf的關鍵字主要有四個,分別是:
nameserver    //定義DNS服務器的IP地址
domain       //定義本地域名
search        //定義域名的搜索列表
sortlist        //對返回的域名進行排序
相關文章
相關標籤/搜索