DNS Automation With CentralNic APIs
If you manage DNS for more than a handful of domains, the Control Panel stops being the fastest tool — the API does. CentralNic Reseller’s KeyDNS service is built to be driven programmatically: every zone, every record, DNSSEC signing and nameserver assignment is a command you can script, put behind your own product, and run across thousands of domains without touching a web form. This guide shows you the real operations you will automate, in the order you tend to need them, grounded in the KeyDNS command set.
It is written for teams automating DNS management at scale — resellers running their own hosting platform, developers wiring DNS into a control panel, and anyone who wants zone changes to happen from code rather than by hand. Each section gives you the concrete command and the rules worth designing around from the start.
Why Automate DNS Through the API
Section titled “Why Automate DNS Through the API”The Control Panel is perfect for a one-off change. But when DNS is part of a
product you sell — provisioning a customer’s site, rotating a mail provider,
publishing a verification record for every domain you manage — you want that
change to be a repeatable command, not a manual click. KeyDNS exposes the whole
lifecycle as a small, consistent command set: AddDNSZone, ModifyDNSZone,
StatusDNSZone, DeleteDNSZone and a set of Query… commands for reading back
what you have. Learn those, and everything else in this guide is a variation on
them.
Create a Zone
Section titled “Create a Zone”A zone is the container for a domain’s records. Before you create one, it is
cheap and worth it to confirm it does not already exist with CheckDNSZone.
-
Check whether the zone exists.
Commandcommand = CheckDNSZonednszone = example.com
-
Create the zone with
AddDNSZone. Supply the initial records inline asrr0,rr1, … — each one a full record line in the format shown in Resource records.Commandcommand = AddDNSZonednszone = example.comrr0 = @ IN A 192.0.2.1rr1 = www IN A 192.0.2.1 -
Confirm the result with
StatusDNSZone. This returns the zone’s SOA details and whether it is signed — a clean way to verify automation did what you expected.Commandcommand = StatusDNSZonednszone = example.com
:::
Add and Manage Records
Section titled “Add and Manage Records”Once a zone exists, you manage its records with ModifyDNSZone. Two parameter
families cover almost everything you will automate:
addrr0,addrr1, … — add a record.delrr0,delrr1, … — remove a record (give the exact record line you want gone).
A common change — repointing a host — is a delete plus an add in the same command:
command = ModifyDNSZonednszone = example.comdelrr0 = @ IN A 192.0.2.1addrr0 = @ IN A 198.51.100.1To read a zone’s records back — for reconciliation, or to diff against your
source of truth before you change anything — use QueryDNSZoneRRList:
command = QueryDNSZoneRRListdnszone = example.comRecord Types You Will Use Most
Section titled “Record Types You Will Use Most”KeyDNS supports the full range of record types. Each record line follows the
standard name TTL IN TYPE rdata shape (TTL is optional). Here are the ones most
automations reach for:
| Type | Purpose | Example record line |
|---|---|---|
| A | Map a host to an IPv4 address | test.example.com. 28800 IN A 192.0.2.1 |
| AAAA | Map a host to an IPv6 address | test.example.com. 28800 IN AAAA 2001:db8:85a3::8a2e:370:7334 |
| CNAME | Alias one name to another | foo.example.com. 28800 IN CNAME bar.example.com. |
| MX | Route mail (priority + mail host) | example.com. 28800 IN MX 10 mail.example.com. |
| TXT | Free text — SPF, verification, etc. | @ IN TXT "v=spf1 ip4:192.0.2.0/24 -all" |
| CAA | Restrict which CAs may issue certs | @ IN CAA 0 issue digicert.com |
Beyond these, KeyDNS also handles ALIAS, DNAME, NS, PTR, SRV, NAPTR, LOC, SSHFP, TLSA, SMIMEA, SVCB, DHCID and the pseudo-records for web and mail forwarding. The Resource records page documents the exact format for every type — treat it as the authority when you build your record templates.
Turn on DNSSEC for a KeyDNS Zone
Section titled “Turn on DNSSEC for a KeyDNS Zone”KeyDNS signs zones for you — you do not manage keys by hand. Enabling DNSSEC is a single flag; the one manual step is publishing the resulting key to the parent zone so the chain of trust validates.
-
Sign the zone. Add
signed = 1when you create it, or turn it on for an existing zone:Commandcommand = ModifyDNSZonednszone = example.comsigned = 1
-
Read the key material with
StatusDNSZone. The response returns the zone’skeydataandkeydsdataentries. Always use the KSK (key-signing key, flag 257) — not the ZSK — to update the parent zone.Commandcommand = StatusDNSZonednszone = example.com -
Publish the DS/key data to the parent zone at the registry, so resolvers can validate the signature. How you submit DS or key data to the registry is covered in DNSSEC.
:::
KeyDNS handles key rollovers as part of the service. The ZSK rolls
automatically every 90 days. The KSK does not roll automatically because it
requires a matching update in the parent zone — you initiate it with
rollover = KSK and, once the parent is updated, finish it with
finishkskrollover = <keytag> (the keytag comes from StatusDNSZone).
Switch Nameservers
Section titled “Switch Nameservers”Managing a zone in KeyDNS only takes effect once the domain actually delegates to
our nameservers. Point a domain at KeyDNS by setting its nameservers on the domain
object with ModifyDomain:
command = ModifyDomaindomain = example.comnameserver0 = anycast1.dnsres.netnameserver1 = anycast2.dnsres.netWhich set you use depends on the service level:
- Anycast —
anycast1.dnsres.net,anycast2.dnsres.net, for zones activated withpremiumdnsset = ANYCAST1. - Whitelabel —
ns1.dnsres.net,ns2.dnsres.net,ns3.dnsres.net(ns1 and ns2 are mandatory, ns3 optional).
The exact hostnames and their IP addresses are listed on KeyDNS Upgrade to Anycast.
Make Bulk Changes Across Many Domains
Section titled “Make Bulk Changes Across Many Domains”The real payoff of automation is applying one change consistently across your whole portfolio — a new SPF record, a CAA policy, a mail-host migration, or a nameserver switch. There is no separate “bulk” command to learn: you compose the same commands you already know into a safe enumerate → apply → verify loop.
-
Enumerate your zones with
QueryDNSZoneListto get the exact set of zones to act on, paging through the full list.Commandcommand = QueryDNSZoneList
-
Apply the change to each zone with
ModifyDNSZone, usingaddrr#/delrr#for record changes — for example, publishing the same CAA policy everywhere:Commandcommand = ModifyDNSZonednszone = example.comaddrr0 = @ IN CAA 0 issue digicert.comFor a fleet-wide nameserver move, loop
ModifyDomainover your domains with the target nameserver set instead. -
Verify each result with
StatusDNSZone(orQueryDNSZoneRRListto confirm records), so a failure on one domain is caught rather than assumed away.
:::
What To Do Next
Section titled “What To Do Next”You now have the full KeyDNS automation loop — create, manage, sign, delegate and scale. These references keep the exact commands and record formats close: