---
title: "Use a managed DNS and CDN that exports · Agent Wranglers"
url: https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/managed-dns-and-cdn
updated: 2026-10-21
licence: "All rights reserved"
---

# Use a managed DNS and CDN that exports your zone

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- Level: Recommended
- Chapter: [Delivery and infrastructure](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure)
- Rule: 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: 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 24.6% of respondents in the Stack Overflow Developer Survey 2026. 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 records in code](https://agentwranglers.se/playbook/infrastructure/networking-and-dns/dns-as-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.
- 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.

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

```sh
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

```hcl
resource "cloudflare_dns_record" "www" {
  zone_id = var.zone_id
  name    = "www.example.com"
  type    = "CNAME"
  content = "example.com"
  proxied = true
  ttl     = 1
}
```

## Sources

- [Import and export DNS records](https://developers.cloudflare.com/dns/manage-dns-records/how-to/import-and-export/)

## Related rules

- [Keep DNS records in code](https://agentwranglers.se/playbook/infrastructure/networking-and-dns/dns-as-code) in Infrastructure

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/managed-dns-and-cdn">Agent Wranglers software choices playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Use Let's Encrypt for TLS certificates](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/lets-encrypt)
- Next: [Use SOPS for secrets](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/secrets-manager-or-sops)
- [Delivery and infrastructure](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure)
