How To Edit a DNS Zone File Via the CLI


This article provides a guide for how to edit a DNS zone file via CLI. This guide assumes root-equivalent access to cPanel VPS or cPanel dedicated server.

How To Edit a DNS Zone File Via the CLI

Making manual edits to a DNS zone is a multiple-step process, if not done correctly it can result in the changes made not going into effect.

Procedure

  1. First, you should make a backup of any zones you plan on editing, if you need to make a copy of all the zones you can create a backup to /var/named-backup using the following command:
    cp -av /var/named /var/named-backup

  2. Next, open the zone file with your desired command line editor, the zone files are located in /var/named and end with the .db extension. After making the desired change to your zone, the serial must be updated. An increased serial indicates that a DNS zone has been changed. Simply increasing the number by one digit is sufficient. An example of the serial from a DNS zone can be seen here:
    2024101502 ;Serial Number
  3. After making the change you can confirm the zones syntax with named-checkzone, if it returns ok you can proceed to reload the zone, otherwise the errors in the zone must be addressed. With named-checkzone you use the domain name, followed by the full path to the DNS zone:
    [root@host ~]# named-checkzone example.tld /var/named/example.tld.db
    zone example.tld/IN: loaded serial 2023062201
    OK
  4. After updating the serial  your DNS server must reload the zone, depending on the name server used the command will vary:

    PowerDNS:

    pdns_control bind-reload-now example.tld

    Bind:

    rndc reload
  5. Lastly, if using DNS cluster with cPanel initiate a sync for the modified zone:
    /scripts/dnscluster synczone example.tld

Conclusion

You now know how to edit a DNS zone file via CLI.

  • dns, dns zone
  • 0 Usuários acharam útil
Esta resposta lhe foi útil?

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...