Knowledgebase: Dedicated Servers
Making quick global changes to DNS
Posted by Help Desk (6), Last modified by NOC Desk Monitors on 07 August 2018 11:43 AM
Firstly before making any changes to named files it is very wise to make a backup:
mkdir /var/named/backup
cp /var/named/*.db /var/named/backup/


Change the serial number to all domains listed, note the format of the date in the example below (2009032410) is:
2009 = year
03 = month
21 = day
10 = revision number for the day
sed -i 's/200[0-9]\{7\}/2009032410/g' *.db*


If you wanted to change a TTL for example 14400 (4 hours) to 3600 (1 hour) :
/usr/bin/replace '14400' '3600' -- /var/named/*.db
or via Perl:
cd /var/named
perl -pi.bak -e "s/14400/3600/g" *.db


*NOTE: Do not adjust below 256 or you may be changing an IP address.

If you wanted to change from an old nameserver name to a new one for all domain zones:
/usr/bin/replace 'ns.oldname.com' 'ns.newdnsname.com' -- /var/named/*.db
repeat for each nameserver (i.e. ns2, ns3 etc).


You can also use perl to do the same. Here is an example that also creates a backup file at the time of making a change:
perl -pi.bak -e "s/oldstring/newstring/g" *.db
example of changing a TTL: perl -pi.bak -e "s/14400/3600/g" *.db

(0 vote(s))
Helpful
Not helpful