Support Center > Knowledgebase > DirectAdmin > DNS > Mass removal of an NS record from all zones, using perl
Mass removal of an NS record from all zones, using perl
If you need to remove an NS record from all zones quickly, perl can be useful.
Let's assume you want to remove all NS records with the value
ns1.domain.com. from all zones.
- First, make a backup of all of your zones, just in case something goes wrong:
cd /var/named
tar cvzf /root/dns_backup.tar.gz *
- Next run the following code:
perl -pi -e 's#^.*NS\s+ns2\.domain\.com\.\n##' *.db
taking note of the character before all literal period characters in the NS value.
- Lastly, you'll need to update the serial on all zones:
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d400
NOTE A zone must have
at least one NS record, or it will not be loaded.
Be sure to check inside a few random zones to ensure it worked.
Check /var/log/messages for any named errors after it gets reloaded.
Also Read