When I've done mass changes of DNS serial numbers, I've tended to use an in place replacement such as:

`perl -pi -e 's/2007\d\d\d\d\d\d/2007102901/' *.com`
and repeat it for the other zone types. The serial number in 'date format' is unique enough that it's just not found anywhere else in the zone files I manage.

Otherwise, moritz's suggestion of a template seems to fit your needs quite well.

Update: To check for an appropriate serial number, something like the code below could be useful:

#!/usr/bin/perl use warnings; use strict; # # warning - untested code. # Let's find the largest serial number of the lot. # my $patt = qr{200\d{7}}; my $dns_zones = '/etc/named/primary/'; # chdir $dns_zones or die "Cannot enter zone file directory.\n"; my @zones = split /\n/, `ls -1`; my $curr_time = get_serial_number(); for my $z (@zones) { open (ZONE, "<", $z) or die("Cannot open zone file $z.\n"); while(<ZONE>) { # # I habitually follow the serial # with a space, a semicolon, a space # and the word 'serial' # if ( /($patt)\s+\;\s+serial/ ) { my $serial = $1; $curr_time = ++$serial if ( $serial > $curr_time ); last; } } close(ZONE); } print "Final time = $curr_time\n"; # # replace in place here. # sub get_serial_number { my @time = localtime(); my $day = substr("0" . $time[3], -2 ); my $month = $time[4] + 1; my $year = 1900 + $time[5]; return $year . $month . $day . "01"; }

In reply to Re: DNS Failover by dwm042
in thread DNS Failover by bjensen34

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.