Mass removal of an NS record from all zones, using perl
Use '%' for wildcards and quotes for "exact phrases"
|Mass removal of an NS record from all zones, using perl||Last Modified: Oct 22, 2015, 11:57 pm|
|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.
NOTE A zone must have at least one NS record, or it will not be loaded.
- First, make a backup of all of your zones, just in case something goes wrong:
tar cvzf /root/dns_backup.tar.gz *
- Next run the following code:
perl -pi -e 's#^.*NS\s+ns2\.domain\.com\.\n##' *.dbtaking 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
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.
2018 JBMC Software, Suite 173 3-11 Bellerose Drive, St Albert, AB
T8N 1P7 Canada. Mon-Fri 9AM-5PM MST