Bulk Change Records
Hi,
I'm trying to make a change inside all DNS zones, The mail record is "mail.domain.com" And I want to change to be "mail.dnszonename.com"
Where dnszonename is true domain name for each domain on server.
I wrote this command:-
for i in `cat /etc/trueuserdomains | cut -d: -f1`; do replace "admin.domain.com" "admin.$i" -- $i.db; done;
But when I ran this, Records changed to be first domain records in "/etc/trueuserdomains"
Could anyone help me to get the correct command to change this record for all DNS zones?
Regards
Zoahir
-
This should work: # for i in $(ls *.db | sed 's/.db//g') ; do sed -i.bak "s/admin.domain.com/admin.$i/g" $i.db ; done
but first# cp -rf /var/named /var/named.bk
sed will create a backup of each zone as well but much easier to revert by just replacing the entire folder from the above backup. You also have to increment the serial in each DNS zone by 1.# 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/;}' '{}' \;
I haven't tested the above so I would try it out on one zone just too make sure it works then# service named reload0 -
Many thx for your answer but I got this inside mail value after running command:- admin.$i. So still this is not the correct value, What do you think? 0 -
It is working now! I changed ' with " for sed command. for i in $(ls *.db | sed 's/.db//g') ; do sed -i.bak "s/admin.domain.com/admin.$i/g" $i.db ; done Many thx again!! 0 -
Sorry please use: # for i in $(ls *.db | sed 's/.db//g') ; do sed -i.bak "s/admin.domain.com/admin.$i/g" $i.db ; done0 -
Beat me to it, glad its working :) 0 -
Hello, I'm happy to see the issue is now resolved. Thank you for updating us with the outcome. 0
Please sign in to leave a comment.
Comments
6 comments