配置dns主从服务。
要求从服务器能够定时从主服务器同步数据。

一.在两个设备进行准备

[root@localhost ~]# systemctl disable firewalld   #关闭防火墙
[root@localhost ~]# systemctl disable selinux     #关闭selinux
[root@localhost ~]# yum install bind -y                 #安装软件

二. 配置

(1)主服务器

[root@localhost ~]# vim /etc/named.conf          #使用文本编辑器打开配置文件   

[root@localhost rhce]# cat  /etc/named.conf 
options {
    listen-on port 53 { 192.168.241.130; };
    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";
    secroots-file    "/var/named/data/named.secroots";
    recursing-file    "/var/named/data/named.recursing";
    allow-query     { any; };
    allow-transfer { 192.168.241.131; };
    recursion yes;

    dnssec-validation no;

    managed-keys-directory "/var/named/dynamic";
    geoip-directory "/usr/share/GeoIP";

    pid-file "/run/named/named.pid";
    session-keyfile "/run/named/session.key";

#zone "." IN {
#    type hint;
#    file "named.ca";
#};
zone "openlab.com" IN {
      type master;
      file "named.openlab.com";
};
zone "192.in-addr.arpa" IN {
      type master;
      file "named.openlab.com";
};

#include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
[root@localhost ~]# vim /var/named/named.openlab.com 

$TTL 1D
@       IN SOA  @ rname.invalid. (
                                             1       ; serial
                                             1M      ; refresh
                                             1M      ; retry
                                             1M      ; expire
                                             3H )    ; minimum
                          NS        ns.openlab.com.
                128     PTR     ns.openlab.com.
                111     PTR      www.openlab.com.
                1D      IN          NS     ns.openlab.com.
ns             1D     IN          A      192.168.241.130

www         1D      IN          A      192.168.241.111
ftp             1D     IN           A      192.168.241.222

(2)从服务器   

    [root@localhost ~]# vim /etc/named.conf #使用文本编辑器打开配置文件

        options {
        listen-on port 53 { 192.168.241.131; };    #允许监听53号端口的主机
        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";
        secroots-file   "/var/named/data/named.secroots";
        recursing-file  "/var/named/data/named.recursing";
        allow-query     { any; };  # 此处也可以写为IP地址或者网段

        zone "openlab.com" IN {
        type slave;#类型为从服务器
        file "slaves/named.openlab";
        masters { 192.168.241.130; };  #此处为主服务器的IP地址

};
zone "241.168.192.in-addr.arpa" IN {
        type slave; # 类型为从服务器
        file "slaves/named.192";
        masters { 192.168.241.130; };  #此处为主服务器的IP地址
};

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐