The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bulk Update DNS Zones

Discussion in 'Bind / DNS / Nameserver Issues' started by rmatakajr, Apr 3, 2012.

  1. rmatakajr

    rmatakajr Member

    Joined:
    Jun 8, 2011
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    Just looking for some clarity here in reguards to updating WHM zones
    I found these 2 suggestions here

    cd /var
    cp -R named named.backup
    replace "OLDIP" "NEWIP" -- /var/named/*.db
    replace "OLDDNS" "NEWDNS" -- /var/named/*.db
    service named restart

    And...

    1) make backup copy of your zones folder cp -a /var/named /var/named.backup

    2) Change into your zone folder cd /var/named ( or /var/named/chroot/named)

    3) use the perl to replace the old ip with new ip

    perl -pi.bak -e "s/oldip/newip/g" *.db


    Now Id rather use the Perl script.. however I have been reading that there
    are serial numbers to the files?

    Can anybody help me clarify what needs to be done here?

    Thanks
    Ricky
     
    #1 rmatakajr, Apr 3, 2012
    Last edited by a moderator: Sep 17, 2013
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello Ricky,

    The serial number would need to be updated for all of the DNS zones. Here's a post on how to perform that action:

    http://forums.cpanel.net/f5/how-incremental-serial-number-dns-zone-211732.html#post873142

    As for clarifying what needs done, first a backup would need to be made of /var/named folder to ensure anything that is modified can be reverted if the change breaks the zones. After you have a backup, then you can use whatever method you prefer to update the IP (whether it be the perl script or the bash command). After making the updates, you'll need to reload the zones:

    Code:
    rndc reload
    You don't necessarily have to restart named, but you could always do that. I typically prefer to reload the zones using rndc instead.

    Thanks!
     
  3. rmatakajr

    rmatakajr Member

    Joined:
    Jun 8, 2011
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Hey Thanks for that update!

    So Just to be clear I would

    1) Back Up All
    # cp -a /var/named /var/named-backup

    2) Replace The IP and DNS

    perl -pi.bak -e "s/oldip/newip/g" *.db
    perl -pi.bak -e "s/olddns/newdns/g" *.db

    3) Update The Serials

    find /var/named/*.db -mtime -1 -exec perl -pi -e 'if (/^\s+(\d{10})\s+;\s+serial/i)


    Just want to be super clear here what Im not missing anything. Im not sure what
    the -pi.bak does in # 2

    Can you just verify for me

    Thnaks!
    Ricky
     
    #3 rmatakajr, Apr 3, 2012
    Last edited by a moderator: Sep 17, 2013
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello Ricky,

    If you make the backup, if anything goes wrong, then you can revert.

    As for the steps, they appear correct, except you've forgotten the step to reload the zones at the very end:

    Code:
    rndc reload
    Also, here is what -pi.bak -e does:

    perl -pi.bak - Google Search

    To quote most those search engine hits:

    "If you want to edit the files in place, editing each file before going on to the next"
    and
    "edits the files in-place, saving original as *.bak"

    Thanks!
     
Loading...

Share This Page