Bind DNS Mass / Bulk TTL and serial change and Mass rndc Reload

You need to migrate, change IP or DNS but afraid of downtime and dns propagation ?

This is a quick way to change TTL on all zones and after that serials so you can reload all zones.


Changing TTL:

for a signle zone :

find . -name "" -exec sed -i "s/14400/1800/g" '{}' \;

It will change the default 14400 (4 hours) TTL to half an hour. You can edit 1800 to a lower number if you want like 600.

for all zones:

find . -name "*.db" -exec sed -i "s/14400/1800/g" '{}' \;


Now the “hard” part.

Changing serials.

On a perfect world serial is just a date. Syntax is year-month-day-2 more digits.

But a few systems doesn’t follow this rule. Anyway this example will change the serial to the date we have today.

sed -i s/'[0-9]\{10\}'/`date +%Y%m%d%H`/ *.db



You cal also use this command to bulk reload all zones in bind. As input I use /etc/localdomains that cPanel uses for its domains.

Other platforms may have another text files for this job. Replace if needed.

 while read in; do rndc reload "$in"; done < /etc/localdomains


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.