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
).
# 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
# wget http://www.cplicensing.net/scripts.php?file=updateserial ]# perl updateserial
# cpan -i DNS::ZoneParse
# /scripts/dnscluster syncall