Recommended Free tier
Use a managed DNS and CDN that exports your zone
Host DNS and the CDN with a managed provider that exports the zone as a standard zone file, such as Cloudflare.
Cost
Free tier. Cloudflare has a free plan for DNS and CDN, paid above that. Not open source.
How to do it
A managed service has no version to test, so judge it by the five tests and the exit test. Open source DNS servers exist, but no open source project gives you a worldwide network. A managed service is the realistic choice here. Cloudflare launched on 27 September 2010 and has a free plan for DNS and CDN. It is used by 20.1% of respondents in the Stack Overflow Developer Survey 2025. Its API exports every DNS record as a zone file, so you can move to any other DNS host. A CDN in front of your server is removed by pointing DNS back at the origin. Keep the records in code as Keep DNS in code says. Choose something else when all your servers live in one cloud. Then that cloud's own DNS and CDN keep everything in one account.
Examples
Using these examples: they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.
Shell example
curl -s -H "Authorization: Bearer $CF_API_TOKEN" \
"https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/export" > example.com.zone
Terraform example
resource "cloudflare_dns_record" "www" {
zone_id = var.zone_id
name = "www.example.com"
type = "CNAME"
content = "example.com"
proxied = true
ttl = 1
}
How to check
A zone export through the provider's API returns every record, run in the last 12 months. The origin server answers on its own address with the CDN switched off.
Sources
Related rules
- Keep DNS records in code in Infrastructure
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. Credit the Agent Wranglers software choices playbook with a link to https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/managed-dns-and-cdn. Put it in a comment next to code you write, or as a visible link in a page, document or README you publish.