【Linux】配置dns主从服务器,能够实现正常的正反向解析

​​​​​​1、首先,在主服务器上配置DNS解析器。打开配置文件/etc/named.conf,添加以下内容:

复制代码
zone"example.com" IN {
    type master;
    file "example.com.zone";
    allow-transfer { slave_ip_address:
};
};

zone"xx.168.192.in-addr.arpa" IN {
    type master;
    file "xx.168.192.zone";
    allow-transfer{ slave_ip_address;
};
};

2、创建正向解析区域文件example.com.zone,并添加以下内容:

复制代码
$TTL 86400
@   IN  SOA     ns1.example.com. admin.example.com. (
                  2022010101 ; Serial
                  3600       ; Refresh
                  1800       ; Retry
                  604800     ; Expire
                  86400 )    ; Minimum TTL
;
@   IN  NS      ns1.example.com.
@   IN  NS      ns2.example.com.
ns1 IN  A       master_ip_address
ns2 IN  A       slave_ip_address
www IN  A       web_server_ip_address

3、创建反向解析区域文件xx.168.192.zone,并添加以下内容:

复制代码
$TTL 86400
@   IN  SOA     ns1.example.com. admin.example.com. (
                  2022010101 ; Serial
                  3600       ; Refresh
                  1800       ; Retry
                  604800     ; Expire
                  86400 )    ; Minimum TTL
;
@   IN  NS      ns1.example.com.
@   IN  NS      ns2.example.com.
1   IN  PTR     ns1.example.com.
2   IN  PTR     ns2.example.com.
10  IN  PTR     www.example.com.

4、在从服务器上进行相同的配置,只需将type master改为type slave

5、重启DNS服务,使配置生效。

复制代码
sudo systemctl restart named
相关推荐
DCTANT12 分钟前
【原创】国产化适配-全量迁移MySQL数据到OpenGauss数据库
java·数据库·spring boot·mysql·opengauss
Touper.21 分钟前
SpringBoot -- 自动配置原理
java·spring boot·后端
黄雪超30 分钟前
JVM——函数式语法糖:如何使用Function、Stream来编写函数式程序?
java·开发语言·jvm
ThetaarSofVenice37 分钟前
对象的finalization机制Test
java·开发语言·jvm
M4K01 小时前
Linux百度网盘优化三板斧
linux
好奇的菜鸟1 小时前
如何在 Ubuntu 24.04 (Noble) 上使用阿里源
linux·运维·ubuntu
bcbobo21cn2 小时前
初步了解Linux etc/profile文件
linux·运维·服务器·shell·profile
wayuncn2 小时前
月付物理服务器租用平台-青蛙云
运维·服务器·服务器租用·服务器托管·物理机租用
望获linux2 小时前
【实时Linux实战系列】CPU 隔离与屏蔽技术
java·linux·运维·服务器·操作系统·开源软件·嵌入式软件
JosieBook2 小时前
【Java编程动手学】使用IDEA创建第一个HelloJava程序
java·开发语言·intellij-idea