powerdns 常见维护备忘

简介:  1. vcapple.com  dev.vpapple.com  qa.vpapple.com  10.199 反向解析  上述 DNS 数据修改时候, 只能够修改 master ( 10.199.132.152 ) 2. 当上述域名数据修改后,  数据会自动同步至 10.199.132.168 (slave) 与 10.199.129.21 (slave) 3. 10.199


1. vcapple.com  dev.vpapple.com  qa.vpapple.com  10.199 反向解析  上述 DNS 数据修改时候, 只能够修改 master ( 10.199.132.152 )

2. 当上述域名数据修改后,  数据会自动同步至 10.199.132.168 (slave) 与 10.199.129.21 (slave)

3. 10.199.132.152 (pdns, master ) 10.199.132.168 (pdns, slave) 与 10.199.129.21 (bind, slave)

4. 10.199.132.152 (pdns, master ) 10.199.132.168 (pdns, slave) 需利用 mysql AB 复制实现数据同步

5. 域名解析在数据库中需要有 NS 记录与 A记录与 SOA 记录


5.1  SOA 为唯一记录

mysql> select domain_id, name, type, content from records where type='SOA';
+-----------+---------------------+------+----------------------------------------------------------------------------+
| domain_id | name                | type | content                                                                    |
+-----------+---------------------+------+----------------------------------------------------------------------------+
|         1 | vcapple.com         | SOA  | dns.vcapple.com dns.vcapple.com 201401104 28800 7200 604800 86400          |
|         2 | 199.10.in-addr.arpa | SOA  | dns.vcapple.com dns.vcapple.com 201401104 28800 7200 604800 86400          |
|         5 | qa.vpapple.com      | SOA  | dns.qa.vpapple.com dns.qa.vpapple.com 2014013002 28800 7200 604800 86400   |
|         6 | dev.vpapple.com     | SOA  | dns.dev.vpapple.com dns.dev.vpapple.com 2014013002 28800 7200 604800 86400 |
+-----------+---------------------+------+----------------------------------------------------------------------------+
4 rows in set (0.00 sec)


5.2  NS 记录必须包含所有 DNS 服务器记录

mysql> select domain_id, name,type, content from records where type='NS' and name='vcapple.com';
+-----------+-------------+------+----------------------------------+
| domain_id | name        | type | content                          |
+-----------+-------------+------+----------------------------------+
|         1 | vcapple.com | NS   | dns.vcapple.com                  |
|         1 | vcapple.com | NS   | dns-slave.vcapple.com            |
|         1 | vcapple.com | NS   | hh-yun-puppet-129021.vcapple.com |
+-----------+-------------+------+----------------------------------+
3 rows in set (0.00 sec)

mysql> select domain_id, name, type, content from recordswhere type='NS' and name='199.10.in-addr.arpa';
+-----------+---------------------+------+----------------------------------+
| domain_id | name                | type | content                          |
+-----------+---------------------+------+----------------------------------+
|         2 | 199.10.in-addr.arpa | NS   | dns.vcapple.com                  |
|         2 | 199.10.in-addr.arpa | NS   | dns-slave.vcapple.com            |
|         2 | 199.10.in-addr.arpa | NS   | hh-yun-puppet-129021.vcapple.com |
+-----------+---------------------+------+----------------------------------+
3 rows in set (0.00 sec)


5.3 域名中需要填写对应的 DNS 服务器记录

mysql> select domain_id, name, type, content, ttl from records where type='A' and name='vcapple.com';
+-----------+-------------+------+----------------+------+
| domain_id | name        | type | content        | ttl  |
+-----------+-------------+------+----------------+------+
|         1 | vcapple.com | A    | 10.199.132.152 |  360 |
|         1 | vcapple.com | A    | 10.199.132.168 |  360 |
|         1 | vcapple.com | A    | 10.199.129.21  |  360 |
+-----------+-------------+------+----------------+------+
3 rows in set (0.00 sec)

5.4 必须具备上述主机的 A 记录, 建议具备PTR 记录

mysql> select id, domain_id, name, type, content, ttl from records where type='A' and name in ( 'dns.vcapple.com', 'dns-slave.vcapple.com', 'hh-yun-puppet-129021.vcapple.com');
+------+-----------+----------------------------------+------+----------------+------+
| id   | domain_id | name                             | type | content        | ttl  |
+------+-----------+----------------------------------+------+----------------+------+
| 5407 |         1 | dns-slave.vcapple.com            | A    | 10.199.132.168 | 3306 |
| 3965 |         1 | dns.vcapple.com                  | A    | 10.199.132.152 |  360 |
| 3672 |         1 | hh-yun-puppet-129021.vcapple.com | A    | 10.199.129.21  |  360 |
+------+-----------+----------------------------------+------+----------------+------+
3 rows in set (0.00 sec)

5.5 子域需重新授权

mysql> select id, domain_id, name, type, content, ttl from records where domain_id=1 and type='NS';
+------+-----------+-----------------+------+----------------------------------+------+
| id   | domain_id | name            | type | content                          | ttl  |
+------+-----------+-----------------+------+----------------------------------+------+
| 3962 |         1 | vcapple.com     | NS   | dns.vcapple.com                  | 360  |
| 5404 |         1 | vcapple.com     | NS   | dns-slave.vcapple.com            | 3306 |
| 5418 |         1 | vcapple.com     | NS   | hh-yun-puppet-129021.vcapple.com |  360 |
| 5441 |         1 | dev.vcapple.com | NS   | dns.dev.vcapple.com              |  360 |  <- 子域授权
+------+-----------+-----------------+------+----------------------------------+------+
4 rows in set (0.00 sec)


6. 经检验 PDNS 新版本才支持通知 bind 进行自动更新 dns 数据功能

[root@pdns-8tedp ~]# rpm -qa | grep pdns
pdns-static-3.4.1-1.x86_64


配置简要说明

[root@pdns-8tedp ~]# cat /etc/powerdns/pdns.conf | grep -v "#" | grep -v ^$

allow-axfr-ips=10.199.196.233,10.199.129.21
allow-recursion=10.199.196.233,10.199.129.21
also-notify=10.199.196.233,10.199.129.21    <-- 旧版本不支持该功能, 该功能能够主动通知从服务器进行数据更新
daemon=yes
launch=gmysql
gmysql-host=127.0.0.1
gmysql-port=3306
gmysql-user=pdns
gmysql-dbname=pdns
gmysql-password=vipshop
guardian=yes
master=yes
recursor=10.199.129.21


参考测试数据库

mysql> select * from domains;
+----+-----------+--------+------------+--------+-----------------+---------+
| id | name      | master | last_check | type   | notified_serial | account |
+----+-----------+--------+------------+--------+-----------------+---------+
|  1 | terry.com | NULL   |       NULL | MASTER |               4 | NULL    |
+----+-----------+--------+------------+--------+-----------------+---------+
1 row in set (0.00 sec)


mysql> select * from records;
+----+-----------+-----------------+------+--------------------------------------------------------+------+------+-------------+----------+-----------+------+
| id | domain_id | name            | type | content                                                | ttl  | prio | change_date | disabled | ordername | auth |
+----+-----------+-----------------+------+--------------------------------------------------------+------+------+-------------+----------+-----------+------+
|  1 |         1 | terry.com       | NS   | dns.terry.com                                          | 3360 | NULL |        NULL |        0 | NULL      |    1 |
|  3 |         1 | dns.terry.com   | A    | 10.199.197.19                                          | 3360 | NULL |        NULL |        0 | NULL      |    1 |
|  4 |         1 | terry.com       | NS   | slave.terry.com                                        | 3360 | NULL |        NULL |        0 | NULL      |    1 |
|  5 |         1 | slave.terry.com | A    | 10.199.196.233                                         | 3360 | NULL |        NULL |        0 | NULL      |    1 |
|  6 |         1 | ttt.terry.com   | A    | 5.5.5.5                                                | 3360 | NULL |        NULL |        0 | NULL      |    1 |
|  7 |         1 | terry.com       | SOA  | dns.terry.com admin.terry.com 4 10800 3600 604800 3600 | 3360 |    0 |        NULL |        0 | NULL      |    1 |
+----+-----------+-----------------+------+--------------------------------------------------------+------+------+-------------+----------+-----------+------+
6 rows in set (0.00 sec)


每次执行DNS 更新, 都需要执行 soa 更新


soa 值来源于上面 domains 表中  notified_serial  列中的值 (select notified_serial from domains where name='terry.com';)


更新 SOA 方法如下, 替换下面关键字 新的 SOA_NUM, 常见新的 SOA 为上一次的数字 +1 的操作

select notified_serial +1 from domains where name='terry.com'
update records set content='dns.terry.com admin.terry.com 新的SOA_NUM 10800 3600 604800 3600' where name='terry.com' and type='SOA';



目录
相关文章
|
人工智能 程序员 测试技术
AI 时代,为什么编程能力≠ 开发门槛
在 2.0 阶段,我们目标是实现面向任务的协同编码模式,人的主要职责转变为任务的下发、干预以及最后结果的审查。在这个过程中,人的实际工作量开始减轻,AI 工作的占比显著提升。目前的 2.0 版本是我们最近上线的。
798 93
|
开发者 Python
新手困扰?该如何了解github的热门趋势和star排行?
新手困扰?该如何了解github的热门趋势和star排行?
1753 0
|
存储 小程序 前端开发
毕业设计:微信小程序健康管理系统的开发与实现
经过调查和走访研发的这套在线健康管理系统,采用微信小程序云开发实现,基于Mongodb数据库进行数据存储,前端使用微信小程序开发实现,后端基于Nodejs开发实现。系统前端用户主要实现查看新闻通知、体检知识、在线体检预约、查看我的预约、修改个人资料等。后台主要实现用户管理、内容管理、活动和预约管理、统计预约用户数等功能。这套系统的上线对于人们健康的管理和体检预约都有很大帮助。...
4004 3
毕业设计:微信小程序健康管理系统的开发与实现
|
测试技术 数据库
『软件测试2』 关于黑盒测试和测试用例的基础知识
该文章讲解了黑盒测试的基本概念以及如何编写有效的测试用例,包括选择合适的输入数据、预期结果的设定和测试执行的步骤。
|
人工智能 缓存 Kubernetes
Kubernetes 集群 Ingress 网关
Kubernetes 集群 Ingress 网关
1076 0
|
资源调度 5G 调度
【5G大唐杯】——5G考试等级考考试基础试题(一)
【5G大唐杯】——5G考试等级考考试基础试题(一)
1266 1
|
监控 前端开发 算法
前端性能体系建设与优化思路
Dev Better技术沙龙-前端性能及新技术实践 学习笔记总结
620 0
|
人工智能 安全 数据安全/隐私保护
【AI 生成式】生成式人工智能存在哪些伦理问题?
【5月更文挑战第4天】【AI 生成式】生成式人工智能存在哪些伦理问题?
【AI 生成式】生成式人工智能存在哪些伦理问题?
|
机器学习/深度学习 存储 传感器
自动驾驶的“天眼”!聊一聊高精地图领域中所有主流的制作方案(下)
在过去几年中,自动驾驶一直是最受欢迎和最具挑战性的话题之一。在实现完全自主的道路上,研究人员利用了各种传感器,如激光雷达、相机、惯性测量单元(IMU)和GPS,并开发了用于自动驾驶应用的智能算法,如目标检测、目标分割、障碍避免和路径规划。近年来,高清晰度(HD)地图引起了广泛关注。
自动驾驶的“天眼”!聊一聊高精地图领域中所有主流的制作方案(下)