大网数据广告活动
服务器运维问答

Automatic way to increase zone file serial number by one in BIND9

· 52CE 我爱测

I've a BIND9 server with a lot of zones and I need to increase the serial number of the zone files by one. Some zones are using the YYYYMMDDXX format but other zones just increase it by one, as they are dynamic DNS zones, so upda…

问题原文

原帖链接 · Vinícius Ferrão · CC BY-SA 3.0

I've a BIND9 server with a lot of zones and I need to increase the serial number of the zone files by one. Some zones are using the YYYYMMDDXX format but other zones just increase it by one, as they are dynamic DNS zones, so updating all by one would do the job for me.

There's a way to do this? I tried with sed but I'm lacking knowledge to do this automatically.

已采纳解答

原帖链接 · MagicJack · CC BY-SA 4.0

This would be pretty difficult to do in 'sed' but it is fairly easy in 'awk'.

 awk '{ if ( $0 ~ /[\t ]SOA[\t ]/ ) $7=$7+1; print}'

If it is an SOA line ("SOA" with a space or tab before and after it) then increment field 7 (serial number). Print every line.

This only increments the serial number which is what was asked, however you'll still need to trigger a reload and notifies to the secondary servers to propagate the changes.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-07-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。