How To: Update All 'named/bind' Zone File Serial Numbers At Once.

Follow

The DNS server package 'BIND' does not check the DNS zone files for changes unless the serial number in each zone file is iterated.

If you have run a command to edit one or many zone files on your server, you will most likely want to update the serial number in each file, so the DNS server knows to parse the files for changes.

Inside each zone file found in /var/named, you will notice a serial number in this format:

2017041507 ;Serial Number

We will use the 'sed' program to modify the serial numbers and replace them all with a new one.

First, take a full backup of the /var/named/ directory, just in case there are any issues, and you need to revert your changes.

cp -rf /var/named /var/named.backup

Next, check to make sure the serial number in the zone file starts with 20, as our sed one-liner will only work with serial numbers starting in 20. It can be edited for other serial numbers as needed, but that will require some further regex knowledge, and is outside the scope of this article.

# grep Serial example.com.db

2017033108 ;Serial Number

Once we have confirmed the serial numbers are in the correct format, we can go ahead and update the serial number of all the zone files with the new one specified. In this case, the new serial number we will give the files is 2013082100 (in bold below).

sed -i 's/20[0-9][0-9]\{7\}/2013082100/g' *.db

Once you've run the command, grep for the serial number again to verify it has updated successfully.

For a further overview of regex syntax, you can visit this link.

 

Have more questions? Submit a request

Comments

Powered by Zendesk