octoDNS vs DNSControl: DNS as Code Compared
Short answer: octoDNS and DNSControl both let you keep DNS records in a file in git, review changes in pull requests and push them to your DNS provider from CI. octoDNS is a Python tool configured in YAML, with each DNS provider as a separate pip package. DNSControl is a single Go binary configured in JavaScript (dnsconfig.js), with every provider built in. Pick octoDNS if your team lives in YAML and Python, and DNSControl if you want one binary and the power of a real language for many similar domains. Both now work with NameOcean DNS, and NameOcean also has the same plan/apply workflow built into its own CLI.
What "DNS as code" means
Instead of clicking records into a control panel, you describe the whole zone in a file. A tool compares the file with what the provider serves and shows a plan ("add this, change that, delete this"). After a review, the same tool applies it. You get:
- History.
git logshows who changed which record and why. - Review. A typo in an MX record is caught in a pull request, not by your customers.
- Repeatability. Moving to another DNS provider is a config change, not an afternoon of copying records.
- Drift detection. A scheduled CI job tells you when someone changed DNS by hand.
Got an idea? Find the perfect domain for it
Our AI domain name generator suggests available names across hundreds of extensions. Free SSL, DNS and Whois privacy included.
octoDNS vs DNSControl at a glance
| octoDNS | DNSControl | |
|---|---|---|
| Started at | GitHub (2017) | Stack Overflow (2017) |
| Written in | Python | Go |
| Zone format | YAML, one file per zone | JavaScript (dnsconfig.js), all domains in one file |
| Install | pip install octodns plus one package per provider | One binary, every provider included |
| See the plan | octodns-sync (dry run by default) | dnscontrol preview |
| Apply | octodns-sync --doit | dnscontrol push |
| Import a live zone | octodns-dump | dnscontrol get-zones |
| Credentials | In the YAML config, usually env/VAR | creds.json, usually $VAR |
| Reuse across domains | YAML anchors, processors | JavaScript variables, functions and loops |
| Several providers at once | Yes: sources and targets per zone | Yes: several DnsProvider() per domain |
| Registrar (nameserver) changes | No | Yes, for registrars it supports |
| Safety checks | Refuses to update or delete more than 30% of a zone (of 10 or more records) without --force | Validates records before pushing; IGNORE() for records managed elsewhere |
octoDNS
octoDNS reads zones from sources (usually YAML files) and syncs them to targets (DNS providers). A zone file looks like this:
# zones/example.com.yaml
'':
- type: A
value: 203.0.113.10
- type: MX
value:
exchange: mail.example.com.
preference: 10
www:
type: CNAME
value: example.com.
With NameOcean as the target:
pip install octodns octodns-nameocean
# config.yaml
providers:
config:
class: octodns.provider.yaml.YamlProvider
directory: ./zones
nameocean:
class: octodns_nameocean.NameOceanProvider
token: env/NAMEOCEAN_API_KEY
zones:
example.com.:
sources: [config]
targets: [nameocean]
# start from what is live now
octodns-dump --config-file config.yaml --output-dir zones example.com. nameocean
# show the plan, then apply it
octodns-sync --config-file config.yaml
octodns-sync --config-file config.yaml --doit
We tested octodns-nameocean on a live zone: a sync without changes plans nothing, and adding, changing and deleting records lands on all four nameservers within seconds. Each sync is one transaction on NameOcean's side, so a refused record means nothing changes. If someone edits the zone between the plan and the apply, the sync is refused instead of overwriting their change.
Good to know: octoDNS's model is strict. Record names are relative, targets end with a dot, and a semicolon in TXT is written \;. Providers that only take certain TTLs (NameOcean takes 5 minutes, 15 minutes, 30 minutes, 1 hour or 1 day) refuse other values unless you set strict_supports: false, which rounds them with a warning.
DNSControl
DNSControl describes every domain in one JavaScript file, so twenty domains with the same mail setup can share a function:
// dnsconfig.js
var REG_NONE = NewRegistrar("none");
var DSP_NAMEOCEAN = NewDnsProvider("nameocean");
function GOOGLE_MAIL() {
return [
MX("@", 1, "smtp.google.com."),
TXT("@", "v=spf1 include:_spf.google.com ~all"),
];
}
D("example.com", REG_NONE, DnsProvider(DSP_NAMEOCEAN),
A("@", "203.0.113.10"),
CNAME("www", "@"),
GOOGLE_MAIL(),
);
// creds.json
{
"nameocean": { "TYPE": "NAMEOCEAN", "token": "$NAMEOCEAN_API_KEY" }
}
dnscontrol preview
dnscontrol push
The NameOcean provider is submitted to DNSControl and passes DNSControl's integration test suite against a live zone (229 tests passed). It becomes available in the DNSControl release after it is merged. Until then, use octoDNS or the NameOcean CLI below.
Good to know: DNSControl's JavaScript is powerful, but it is a program. Keep it boring: plain records first, functions only for what really repeats. IGNORE() keeps records that another system manages, such as ACME challenges or Kubernetes' external-dns, from being deleted.
Without either tool: the NameOcean CLI
If all your zones are on NameOcean, you don't need a third-party tool at all. The nameocean CLI and the API have the same workflow built in, with a YAML file that has a published JSON Schema for editor autocompletion:
nameocean dns export example.com > dns.yaml
nameocean dns plan -f dns.yaml
nameocean dns apply -f dns.yaml
It also does what octoDNS and DNSControl can't: nameocean dns history shows who changed each record and when (dashboard, API key or AI app), and nameocean dns revert undoes a single change. The DNS as code guide has a ready GitHub Actions workflow.
Which one should you pick?
- One DNS provider, a few zones: the provider's own tooling if it has one (for NameOcean, the CLI). One less dependency.
- Several providers, or a planned move: octoDNS or DNSControl, so the zone file is the same whichever provider serves it.
- Many similar domains: DNSControl, for the functions and loops.
- A Python shop that already reviews YAML: octoDNS.
Whichever you choose, give its API key only DNS permissions, limit it to your CI's IP addresses where the provider allows it, and run the plan on every pull request so reviewers see the real change, not just the diff of a file.
FAQ
Can I use octoDNS and DNSControl on the same zone?
Not at the same time. Each one makes the zone match its own file and deletes what is not in it. Use IGNORE() in DNSControl, or octoDNS's ignored records, if another tool owns part of a zone.
Does DNS as code work with DNSSEC?
Both tools can manage DS records for delegated subdomains. Signing the zone itself is usually a provider setting; on NameOcean it is one switch in the dashboard or the API.
What about Terraform?
Terraform also manages DNS, record by record, as part of the rest of your infrastructure. If you already use it for servers, that can be enough. octoDNS and DNSControl are better when DNS is the main job: they see the zone as a whole, show a readable plan, and make moving between providers easy.
Sources
Got an idea? Find the perfect domain for it
Our AI domain name generator suggests available names across hundreds of extensions. Free SSL, DNS and Whois privacy included.
Read in other languages: