Update Multiple DNS Zones with Find and Replace


This article provides a guide for how to update multiple DNS zones with find and replace (sed). This guide is intended for WHM cPanel VPS and dedicated server administrators.

How to Update Multiple DNS Zones with Find and Replace (sed)

We can use sed (a find and replace command line tool) to quickly replace all instances of a specific string in DNS zones with another string.

For example, if several DNS zones are using the NS value 'ns1.servername.us' but you want to replace it with 'ns1.serverprovider.net', then this would be a perfect application of this tool.

To update multiple DNS zones with find and replace using sed, follow the steps below:

  1. Login via SSH as root.
  2. Run the following commands:
    cd /var
    cp -R named named.backup060924
    sed -i 's/ns1.servername.us/ns1.serverprovider.net/g' /var/named/*.db
    sed -i 's/ns2.servername.us/ns2.serverprovider.net/g' /var/named/*.db
    sed -i 's/2024060601/2024060921/g' /var/named/*.db
    systemctl restart named
    systemctl status named

These commands will take a full backup of the 'named' directory, replace every instance of 'ns1.servername.us' with 'ns1.serverprovider.net' and every instance of 'ns2.servername.us' with 'ns2.serverprovider.net', update the zone serial numbers, and restart named.

Conclusion

You now know how to update multiple DNS zones with find and replace, using sed.

  • sed, dns records, named
  • 0 Utenti hanno trovato utile questa risposta
Hai trovato utile questa risposta?

Related Articles

Remove a Service from ChkServd Monitoring for cPanel Servers

This guide requires root user account in server. In some circumstances, ChkservD cPanel...

How to Edit Zone File and Setup DNS Forwarding

To perform DNS forwarding, change your zone file, (MX, A-Records & CNAME) using the following...

Assigning a Dedicated IP Address to a Subdomain using WHM

To assign a dedicated IP address to a subdomain, perform the following steps: Step 1: Add the...

Update Nameservers for Domains Registered at GoDaddy

After signing up for a hosting account, you will receive a Welcome email containing important...

Guide to Domain EPP Status Codes

EPP Status Codes are used by the Domain Registry to signify the status of a particular domain...