Introduction
You may need to make bulk changes to your DNS zones, which is not currently supported through the DNS Zone Editor. For example, when changing your domains to point to a new set of private nameservers.
If your DNS zones have no customizations, you can edit the DNS Zone Template and then reset the DNS zone to apply the changes. However, this is not practical in all cases because zones may have customizations, and this will remove those customizations.
Procedure
Experienced system administrators should explore manually editing all DNS Zones from the command line. For instance, if you want to update the nameservers in all DNS zones from ns1.example.com and ns2.example.com to ns1.example.net and ns2.example.net, you could do so using customized sed and find Linux commands after backing up all zones in the /var/named/ directory.
SafeAdmin Certified system administration service providers are listed on the SafeAdmin Certified Services page for your convenience.
The following is an example of the procedure to change nameservers for all domains using the command line.
We strongly recommend backing up all DNS zones prior to making bulk changes. It is the responsibility of the administrator performing these changes to ensure that all commands are run correctly.
- To back up all zones, run the following command:
cp -rf /var/named{,.backup}
- Replace the nameservers used. In the following examples, we will use
ns1.olddomain.tld
andns2.olddomain.tld
as the current nameservers, andns1/2.newddomain.tld
for the updated records, be sure to update theoldns
andnewns
variables.
oldns="ns1.olddomain.tld"; newns="ns1.newdomain.tld" ; find /var/named/*.db -exec perl -pi -e "s/(?<=IN\s\NS\s)$oldns/$newns/g" '{}' \;
- Run the command a second time, substituting
ns1
forns2
. - To update the SOA record, run the following command. The SOA record will contain your ns1 nameserver's name, so ensure the variables are updated appropriately.
oldns="ns1.olddomain.tld"; newns="ns1.newdomain.tld" ; find /var/named/*.db -exec perl -pi -e "s/$oldns/$newns/g if /SOA/" '{}' \;
- Update the serial records for all modified DNS zones:
find /var/named/*.db -mtime -1 -exec perl -pi -e 'if (/^\s+(\d{10})\s+;\s?(?i)serial/i) { my $i = $1+1; s/$1/$i/;}' '{}' \;
- Restart the DNS service to apply changes:
/scripts/restartsrv_named
- Verify that the zones were updated correctly.
- (Optional) If DNS Clustering is enabled, sync all zones:
/scripts/dnscluster syncall
Comments
0 comments
Article is closed for comments.