How to preform mass changes to DNS zones

The following will do a regex match through /var/named and change anything in a .db file (your DNS zones) that matches the string “example1.com” to “example2.com”. We have found the most common need for this is if someone had the nameserver changed or had them listed wrong in the basic cPanel section when they created their accounts and the zones were created with the wrong NS entries. Ultimately this process can be used to make any regex change to the zone file by altering the command fed to sed in step one(s/example1.com/example2.com/g).

  1. Duplicate the zones with changes, move the originals, and implement the changes:
    # cd /var/named
    # mkdir newzones
    # for i in `ls *.db`;do cat $i|sed s/example1.com/example2.com/g >> ./newzones/$i;done# mkdir oldzones
    # mv /var/named%%/*%%.db /var/named/oldzones
    # cp *.db /var/named/newzones /var/named
  2. Download and run the update user domain script from cplicenseing.net (this will use Perl to parse the DNS zones and update all the serials):
    # wget http://www.cplicensing.net/scripts.php?file=updateserial
    ]# perl updateserial
    • The Perl module dnszone parse is needed if you don't have it run:
      # cpan -i DNS::ZoneParse
    • Note: If the above link is ever broken check the download section of the knowledge base and/or contact support.
  3. Sync your new zones with the other zones in your dns cluster (you can skip this if you don't run DNS clustering):
    # /scripts/dnscluster syncall