Server Administration & Management

How to Mass updating zone file serial numbers using 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).


July 1, 2012 - Posted by | Tips & Tricks, Unix/Linux | , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: