【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
相关推荐
god002 分钟前
Selenium等待判断元素页面加载完成
java·开发语言
TiDB 社区干货传送门3 分钟前
【附操作指南】从 Oceanbase 增量数据同步到 TiDB
linux·服务器·数据库·tidb·oceanbase
红辣椒...8 分钟前
安装next-ai-draw-io
linux·运维·服务器
CoderYanger10 分钟前
贪心算法:3.最大数
java·算法·leetcode·贪心算法·1024程序员节
遇见火星11 分钟前
Linux性能调优:详解磁盘工作流程及性能指标
linux·运维·服务器
专注VB编程开发20年12 分钟前
多线程解压安装ZIP,EXE分析-微软的MSI安装包和 .NET SDK EXE
linux·运维·服务器·microsoft·.net
爱学习的小可爱卢14 分钟前
JavaEE进阶——MyBatis-Plus新手完全攻略
java·mybatis-plus
码界奇点15 分钟前
Java Web学习 第15篇jQuery万字长文详解从入门到实战解锁前端交互新境界
java·前端·学习·jquery
CoderYanger16 分钟前
贪心算法:5.最长递增子序列
java·算法·leetcode·贪心算法·1024程序员节
沉迷技术逻辑18 分钟前
Docker部署与常用命令
java·docker·eureka