description Cloudflare Workers DNS Overview
This represents the cutting edge of DNS management: programmable DNS. Instead of just pointing records, you can write code (using Cloudflare Workers) that executes logic *during* the resolution process. This allows for dynamic record manipulation, A/CNAME swapping based on time, or complex routing logic that traditional DNS records cannot handle. It is for advanced users building highly dynamic services.
help Cloudflare Workers DNS FAQ
Can a Cloudflare Worker really change an authoritative DNS answer while a query is being resolved?
Ordinary Cloudflare Workers run on HTTP requests, not inside Cloudflare Authoritative DNS resolution, so they cannot directly rewrite an A or CNAME response per DNS query. A Worker can instead call the Cloudflare DNS API to update records, or return dynamic HTTP responses after a proxied hostname has resolved.
How would I build dynamic DNS with Cloudflare Workers?
A common design exposes an authenticated Worker endpoint that updates a Cloudflare DNS record through the DNS API when an IP address changes. The new answer remains subject to DNS caching and the record's TTL, so this is not instantaneous request-by-request routing.
Can Cloudflare Workers perform DNS lookups from their own code?
Yes, Workers can use supported DNS APIs, including Node.js DNS functions backed by DNS over HTTPS to Cloudflare's 1.1.1.1 resolver. Those lookups count as Worker subrequests and resolve names for the Worker rather than modifying authoritative answers.
Should I use DNS changes or a Worker for traffic splitting and failover?
Use a Worker route when decisions must happen on every HTTP request, because it can inspect headers, cookies, paths, and other request data without waiting for DNS caches. Cloudflare Load Balancing is a closer fit for health-checked origin failover, while DNS API updates suit slower infrastructure changes.
explore Explore More
Similar to Cloudflare Workers DNS
See all arrow_forwardReviews & Comments
Write a Review
Be the first to review
Share your thoughts with the community and help others make better decisions.