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 Users Found This Useful
Was this answer helpful?

Related Articles

Guide to Domain EPP Status Codes

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

Addon Domain Vs Alias Domain

The table below lists some key characteristics of Addon Domain and Alias Domain....

Disable Network Manager on CentOS 7

This article will provide the steps to disable Network Manager in CentOS 7. Network Manager is...

Disable Network Manager on CentOS 6

This article will provide the steps to disable Network Manager in CentOS 6. Network Manager is...

Video: How to Setup Domain Redirects in cPanel

This video tutorial provides Step-by-Step instructions how to setup domain redirects in cPanel...