inside the mind of a linux admin

Mass updating zone file serial numbers with sed

If you’ve ever administered a DNS (name server), than you know that serial numbers mean a lot. But what happens when you have several [hundreds|thousands] of zone that you need to make a mass-change to. That’s easy enough, there’s tons of ways to do that with sed, awk, or simple tools like “replace”. However, once you’ve done the easy work, you still need to update all the serial numbers as well. Here’s how I saved myself hours of manual labor:

If you’re even reading this article, it’s expected that you at least know that a serial number is in the form YYYYMMDDNN where NN is the update number for that day. So the serial number from my post today would be 2011031900.

Now here’s how you tell sed what you want done (note, this formula assumes that your previous serial numbers were post-2000):

# sed -i ‘s/20[0-9][0-9]\{7\}/2011031900/g’ *.db

This says to replace any text starting with 20+[any two numbers 0-9] and followed by another 7 digits with the string: 2011031900

Problem solved, check out your zones now (provided they end in the standard format of domain.tld.db).

Related Posts

How to revert back to X11 / Xorg from Wayland

Wayland is intended as a “simpler replacement for X”, and is getting quite a bit of hype around the Linux community. So much so, that it’s the default in the latest versions of Fedora, GNOME, KDE and others. While Wayland may be the future, it really is in future. At least for Ubuntu 17.10. The […]

Read More

Touchpad stops working after sleep + resume (Fedora 26 on Dell XPS)

After recently upgrading my Dell XPS 13 w/Touchscreen to Fedora 26, the touchpad suddenly stopped working upon resuming from sleep mode. It was reproduced 100% of the time, and required a complete restart in order to get the touchpad working again. There have been several forum posts and bug reports regarding others experiencing these exact […]

Read More

1 Comment

  • Luís Miguel Sequeira on Wednesday, February 27, 2013

    Works like a charm, thanks for the snippet. You might need to add -E under FreeBSD 9.X to get sed to behave like the GNU sed.

Leave a Reply

Your email address will not be published. Required fields are marked *

Twitter: kireguy

Tweeter button Facebook button Myspace button