DNS主从服务器搭建

1、安装bind软件包

[root@localhost cdrom]# yum install -y bind*

...

完毕!

  1. 查看需要配置的dns服务的文件是否全部存在

[root@localhost etc]# ll | grep named

drwxr-x---.  2 root named        6 2月  25 2019 named     

-rw-r--r--.  1 root root       621 2月  25 2019 named-chroot.files

-rw-r-----.  1 root named     1705 2月  25 2019 named.conf         --主配置文件

-rw-r-----.  1 root named      931 6月  21 2007 named.rfc1912.zones    --区域配置文件

-rw-r--r--.  1 root named     1886 4月  13 2017 named.root.key

 

2、#主DNS配置

1)全局配置文件

[root@localhost named]# vi /etc/named.conf

options {

        listen-on port 53 { any; };

        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";

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

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

        #allow-query     { any; };

        allow-transfer {192.168.154.140;};

2)主配置文件

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

zone "linux.com" {

        type master;

        file "linux.com.zone";

        also-notify { 192.168.154.140; };

          allow-transfer {192.168.154.140; };

};

3)区域配置文件

[root@localhost named]# vi linux.come.zone

$TTL 1D

@       IN SOA  dns.linux.com.  root.linux.com. (

                                        2020111601      ; serial

                                        1D      ; refresh

                                        1H      ; retry

                                        1W      ; expire

                                        3H )    ; minimum

 

            IN      NS      dns.linux.com.       主DNS        

        IN      NS      www.linux.com.     从DNS

aa      IN      A       192.168.154.141

dns     IN      A       192.168.154.111     主DNS

www     IN    A       192.168.154.140      从DNS

ftp     IN      A       192.168.154.115

写dns

[root@localhost]# vi /etc/resolv.conf

#Generated by NetworkManager

search localdomain

#nameserver 192.168.154.2

nameserver 192.168.154.111

重启服务

[root@localhost ~]# systemctl restart named

                                     

从DNS配置

写dns

[root@localhost slaves]# vi /etc/resolv.conf

#Generated by NetworkManager

search localdomain

#nameserver 192.168.154.2

nameserver 192.168.154.111

配置全局配置文件

[root@localhost slaves]# vi /etc/named.conf

options {

        listen-on port 53 { any; };

        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";

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

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

        #allow-query     { any; };

        allow-transfer {192.168.154.111;};

配置主配置文件

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

zone "linux.com" {

        type slave;

        file "slaves/linux.com.zone";

        masters {192.168.154.111;};

 };

重启服务让dns自动同步

[root@localhost slaves]# ls

[root@localhost slaves]# rndc reload

server reload successful

[root@localhost slaves]# ls

linux.com.zone

 

你可能感兴趣的:(linux,centos,dns服务器)