Reseting a BIND zone file serial number

One of the most annoying things that can happen when using BIND9 with a lot of slave servers is, mistakingly, setting the serial number for a zone file in the future.

Let’s assume that your are using the current date plus a 2-digit number as your serial number. This is a pretty standard thing that lots of admins use:

serial 2011022700;

Then you or someone else not paying attention when updating the zone file set the serial to 201102701. This is missing a “2” digit, thus setting the serial higher - or in the future in our case. When reloading bind this broken serial will be pushed to all the slaves and all further updates to your zone file will have to use the broken serial number and just increment it instead of using your current date. This is because if you just fix the serial number on the master to the current date, the slaves won’t be notified of the update because the serial on the master will be a lower number. It will work but it will break the consistency and standards that you worked so hard in implementing in your systems.

So to fix it you have two choices:

1) Fix the serial number on the master and then write a bash / perl / python script to ssh into all the slaves, delete the broken zone file from all of them and restart bind. This will force the slaves into re-requesting the zone file from the master, zone file that will have the corrected serial. This method will work but it involves more work and might go wrong if you are not careful.

2) Use a functionality that is available in BIND9 and documented in their manual. It involves incrementing the serial number on the master with the highest value possible. This will effectively “reset” the serial allowing you to start over from whatever value you want. The highest value possible is: 2^31-1 = 2147483647

The steps are:

Add the number 2147483647 to your broken serial number and write it in your zone file on the master server:
In our case: 2147483647 + 2011022701 = 4158506348
Reload your zone file: rndc reload
This time your zone file will be pushed again on all your slaves because it is the highest available value you can increment it with
Reset the serial number to the value you want, the correct value - the current date: 2011022700
Reload the zone file on the master server again: rndc reload
This time the update will work and the master and all the slaves will have the correct serial number

Hope it helps!

For reference this is the manual page: http://www.bind9.net/manual/bind/9.3.2/Bv9ARM.ch08.html