1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to incremental serial number in dns zone?

Discussion in 'Bind / DNS / Nameserver Issues' started by vanessafan, May 27, 2011.

  1. vanessafan

    vanessafan New Member

    Joined:
    May 26, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    after a dns zone do you need to update the serial number? and if so how do you do that?
     
  2. astopy

    astopy Member

    Joined:
    Apr 3, 2003
    Messages:
    174
    Likes Received:
    0
    Trophy Points:
    16
    If you're editing it in WHM, it'll increment the serial number automatically. If you're editing it by hand for some reason, just increment the serial number by hand as well.
     
  3. vanessafan

    vanessafan New Member

    Joined:
    May 26, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    for a given file domain.com.db how do you do this?
    maybe via the command line?
    i need to do it for a couple hundred domains
     
  4. astopy

    astopy Member

    Joined:
    Apr 3, 2003
    Messages:
    174
    Likes Received:
    0
    Trophy Points:
    16
    The format of the zone files should be predictable, so you should be able to write a script to edit them all. There isn't an easy, ready-made way of doing it as far as I know.

    The other way would be to edit each file with vim, emacs, nano, whatever. That would obviously be pretty time consuming though.
     
  5. cPanelMichael

    cPanelMichael Well-Known Member
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    17,523
    Likes Received:
    26
    Trophy Points:
    48
    Hello :)

    This could be achieved using a Perl command like the one posted below. Please notice that /var/named is backed up before running this command so it can be restored if any errors occur:

    Code:
    # cp -a /var/named /var/named-backup 
    # find /var/named/*.db -mtime -1 -exec perl -pi -e 'if (/^\s+(\d{10})\s+;\s+serial/i) { my $i = $1+1; s/$1/$i/;}' '{}' \;
    This will increment the serial for all DNS zones within the /var/named directory.

    Thank you.
     

Share This Page