【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
相关推荐
卓码软件测评1 小时前
第三方软件测试机构【性能测试工具用LoadRunner还是JMeter?】
java·功能测试·测试工具·jmeter·性能优化
知星小度S1 小时前
系统核心解析:深入操作系统内部机制——进程管理与控制指南(一)【进程/PCB】
linux·运维·服务器·进程
编码浪子4 小时前
趣味学RUST基础篇(异步)
服务器·rust·负载均衡
Lionel_SSL5 小时前
《深入理解Java虚拟机》第三章读书笔记:垃圾回收机制与内存管理
java·开发语言·jvm
记得开心一点嘛5 小时前
手搓Springboot
java·spring boot·spring
老华带你飞5 小时前
租房平台|租房管理平台小程序系统|基于java的租房系统 设计与实现(源码+数据库+文档)
java·数据库·小程序·vue·论文·毕设·租房系统管理平台
独行soc5 小时前
2025年渗透测试面试题总结-66(题目+回答)
java·网络·python·安全·web安全·adb·渗透测试
脑子慢且灵5 小时前
[JavaWeb]模拟一个简易的Tomcat服务(Servlet注解)
java·后端·servlet·tomcat·intellij-idea·web
Empty_7776 小时前
SELinux安全上下文
linux·服务器·安全
华仔啊6 小时前
SpringBoot 中 6 种数据脱敏方案,第 5 种太强了,支持深度递归!
java·后端