DNS Locations, Resolver Endpoints, and Location Matching
How Gateway DNS locations identify networks, which resolver endpoints to use, and how DNS64 and policies apply without a device agent.
This page summarizes Cloudflare Gateway documentation on DNS locations: mapping offices, homes, and data centers to resolver endpoints so DNS policies apply before a connection starts. DNS location setup filters DNS traffic only; HTTP and network filtering require the Cloudflare One Client, proxy endpoints, or network tunnels described in Traffic controls — Choose a connection method.
DNS locations: filter DNS for a whole site without installing agents
Section titled “DNS locations: filter DNS for a whole site without installing agents”DNS locations are a collection of DNS endpoints mapped to physical places such as offices, homes, or data centers. Pointing a network’s resolver at Gateway is the fastest way to start filtering queries from that location.
DNS locations allow you to filter DNS traffic from networks without deploying the Cloudflare One Client. By configuring your network’s DNS resolver to point to Cloudflare Gateway, Gateway applies DNS policies to all queries from that location.
— Cloudflare, Connectivity options
Secure Web Gateway inspects DNS queries—the lookups that turn names like example.com into IP addresses—so threats can be blocked at the earliest stage of a connection. What is DNS filtering? explains that a filtering resolver refuses or redirects resolutions for domains your policies block. DNS filtering applies only to hostnames, not paths, ports, or protocols; users can still bypass it with a known IP, VPN, or non-filtered resolver, which is why many teams treat DNS as a first layer and add fuller SWG controls later (DNS filtering vs. Secure Web Gateway).
Choose agentless DNS locations when you want to try filtering without software, do not need per-user identity on the network, or want blanket policies for every device at a site (Onboard DNS for a network). For roaming users and identity-based rules on managed laptops, Cloudflare recommends the Cloudflare One Client; in DNS only mode it forwards DNS to your account resolver without routing other traffic (Client modes).
| Connection method | DNS policies | Network / HTTP policies | Typical use |
|---|---|---|---|
| Cloudflare One Client (WARP) | Yes | Yes | Managed laptops and phones |
| DNS resolver configuration (DNS locations) | Yes | No | Offices, guest Wi‑Fi, quick rollout |
| WARP Connector | DNS + network via gateway host | Per deployment | Servers, routers, IoT without per-device agents |
| Network tunnel (Magic WAN) | Yes | Yes | Sites routing all traffic through Cloudflare |
For subnets where you cannot install a client on every device, Cloudflare recommends the WARP Connector on one Linux host instead of legacy cloudflared proxy-dns (changelog: proxy-dns removal).
How Gateway matches a DNS query to a DNS location
Section titled “How Gateway matches a DNS query to a DNS location”Gateway must attribute each query to a location so the right DNS policies and logs apply. The match depends on how the query reaches Gateway (DNS query location matching):
- DNS over HTTPS (DoH) — location is determined by the location’s unique DoH hostname (subdomain).
- IPv4 (UDP/TCP, plain DNS) — location is determined by the public source IPv4 address of the network (you register source IPs on the location unless you use a dedicated destination IPv4).
- Otherwise (typically IPv6) — location is determined by the unique IPv6 resolver address assigned to that location.
When you connect a network without the client, verify under Traffic controls → Resolver endpoints that the Source IPv4 Address matches the site’s public IP for IPv4 queries. For IPv6, DoT, or DoH, configure the forwarding address or hostname shown for that location (Connect DNS locations).
Service providers and agencies with unstable source IPs often send queries to unique DoH/DoT hostnames or unique destination IPv6 addresses per location (Gateway DNS for ISP).
Generic DoH and DoT endpoints with location selectors
Section titled “Generic DoH and DoT endpoints with location selectors”You can use shared hostnames and pass the location explicitly:
- DoH: send requests to
dns.cloudflare-gateway.comwith headercf-dns-location: <DoH_subdomain>(Use generic DoH endpoint). - DoT: use
dns.cloudflare-gateway.comwith EDNS OPT code 65011 whose value is the location name (Configure your DoT client).
Per-location endpoints look like https://<YOUR_DOH_SUBDOMAIN>.cloudflare-gateway.com/dns-query (Filter DoH requests by location).
Identity-based DoH without the One Client
Section titled “Identity-based DoH without the One Client”Location policies require the location-specific DoH URL. User-specific policies require a DoH token in the CF-Authorization header on https://<ACCOUNT_ID>.cloudflare-gateway.com/dns-query (Generate a DoH token, Send an authenticated DoH query). Tokens expire in 24 hours; Cloudflare recommends a refresh flow rather than generating a token per query.
Add a DNS location: endpoints, ECS, DNS64, and secure locations
Section titled “Add a DNS location: endpoints, ECS, DNS64, and secure locations”Create locations under Zero Trust → Traffic controls → Resolver endpoints (Add a DNS location). For each location, Gateway assigns IPv4/IPv6 addresses and DoT/DoH hostnames shown under Setup instructions (DNS resolver IPs and hostnames).
Optional toggles that matter in production:
| Setting | Purpose |
|---|---|
| Enable EDNS client subnet | Sends a privacy-preserving /24 of the client IP to authoritative nameservers for better geo answers (Gateway locations) |
| Set as Default DNS Location | Default DoH endpoint for the organization |
| Enable DNS64 | Synthesize AAAA from A for IPv6-only networks with NAT64 (DNS64) |
| Source IP filtering | Restrict which networks may use IPv4, IPv6, or DoT endpoints |
Secure DNS locations (for protective DNS–style deployments) require stricter endpoint hardening: BYOIP where used, source filtering on IPv4/IPv6/DoT, and source filtering or token auth on DoH (Secure DNS locations).
You may skip configuring the IPv4 endpoint if the site is IPv6-only, all DNS uses DoH from browsers, or all devices use the Cloudflare One Client (IPv4 and IPv6 DNS). If Gateway shows Your source IPv4 address is taken, another tenant may have claimed that IP on the shared resolver model; use IPv6, DoH, dedicated IPv4, or contact support (IPv4 and IPv6 DNS).
Internal names and split DNS use resolver policies (Enterprise) to forward queries to private DNS; locations alone only apply Gateway’s resolver path to the queries you send them (Connectivity options).
DNS64 on Gateway: location setting, EDNS, and DoH headers
Section titled “DNS64 on Gateway: location setting, EDNS, and DoH headers”DNS64 synthesizes AAAA records from A records when no AAAA exists, for IPv6-only networks that use NAT64. Gateway uses prefix 64:ff9b::/96; DNS64 synthesizes answers; NAT64 translates traffic (DNS64).
DNS64 is off by default. These mechanisms independently request synthesis (Request DNS64):
| Mechanism | How to enable |
|---|---|
| DNS location | Enable DNS64 or API dns64_enabled: true |
| EDNS | Empty option 65051 on the query (UDP/TCP/DoT; wire-format DoH) |
| DoH | Header cf-dns-options: dns64 |
Turn on Enable DNS64 for a location, or include an empty EDNS option 65051 in individual queries. Both mechanisms support UDP, TCP, DNS over TLS (DoT), and DNS over HTTPS (DoH).
— Cloudflare, Request Gateway DNS64 through DNS locations and EDNS
Example EDNS test:
dig @"<DNS_RESOLVER_IP>" ipv4only.arpa AAAA +ednsopt=65051 +shortEligible synthesis for ipv4only.arpa returns 64:ff9b::c000:aa and 64:ff9b::c000:ab (Verify DNS64). DNS64 does not alter existing AAAA answers, A queries, policy block responses, or overrides; clients that validate DNSSEC may reject synthesized records (Verify DNS64).
Configure browsers and OSes to use a location DoH endpoint
Section titled “Configure browsers and OSes to use a location DoH endpoint”DNS over HTTPS lets you filter encrypted DNS by location without the One Client. Browsers must use your location’s https://<YOUR_DOH_SUBDOMAIN>.cloudflare-gateway.com/dns-query, not a generic public DoH URL, or Gateway will not apply your policies (Configure browser for DoH). Safari does not support DoH (Configure browser for DoH). Windows 11 can register DoH server addresses with Add-DnsClientDohServerAddress after resolving A/AAAA for the location hostname (Configure operating system for DoH).
Build policies with the DNS Location selector for location-based DoH (DNS over HTTPS). Step-by-step browser setup also appears in Onboard DNS — Change DNS resolver in browser and Update local DNS resolver.
When multiple DNS locations exist, MDM deployments can set the client gateway unique id (DoH subdomain) so DNS-only mode targets the correct location (Parameters).
Block pages, dual-stack networks, and Mesh on DNS hosts
Section titled “Block pages, dual-stack networks, and Mesh on DNS hosts”When a policy blocks with a custom block page enabled, DoH may return the block page IP 162.159.36.12; with the block page disabled, the answer may be 0.0.0.0 (Send an authenticated DoH query). On dual-stack networks, DNS and the browser may use different IP versions, so the block page can fail to load or show without policy context (rule ID, reason).
On dual-stack networks, the source IP address of the DNS query and the block page connection may differ. The DNS query may go over IPv4 while the browser connects to the block page over IPv6, or the other way around. When this happens, the block page may fail to load. It may also display without policy context (rule ID, block reason, or custom redirect parameters).
— Cloudflare, Gateway block page — Dual-stack networks
Configure a dedicated DNS resolver IP for the DNS location so the block server can identify the account by destination IP regardless of source address (Gateway block page).
Cloudflare Mesh nodes run in Traffic and DNS mode and redirect host DNS to Gateway, which conflicts with co-resident resolvers (Active Directory DNS, Pi-hole, Unbound, BIND, dnsmasq).
If your server runs a DNS service, do not install the Mesh node on that host. Instead, install the node on a separate machine on the same subnet and use CIDR routes to make the DNS server reachable.
— Cloudflare, Mesh best practices
Common mistakes when using DNS locations
Section titled “Common mistakes when using DNS locations”- Pointing only some clients at Gateway while others use ISP DNS—policies and logs will not cover the whole site (Securing guest wireless networks).
- Using shared IPv4 resolver IPs without registering source IPs—Gateway cannot attribute traffic (Source IP).
- Expecting DNS locations to enforce HTTP or identity without DoH tokens or the One Client (Connectivity options).
- Enabling DNS64 without NAT64 for
64:ff9b::/96on the network (DNS64). - Installing Mesh on a DNS server host instead of a separate node with CIDR routes (Mesh best practices).
How to check this on your site
Section titled “How to check this on your site”- Confirm devices send DNS to Gateway: either the Cloudflare One Client is enrolled, or the network/browser uses your location’s resolver IPs or DoH hostname (Test DNS filtering — Prerequisites).
- In Resolver endpoints, open the location and verify Source IPv4 (for plain DNS over IPv4) or the correct DoH subdomain / IPv6 resolver for your protocol.
- Apply a test DNS policy (block a known test domain or category) and resolve the name from a client on that network; compare answers and Gateway DNS logs.
- If you enabled EDNS client subnet, run the
o-o.myaddr.google.comDoH check from Test EDNS configuration and confirm the returned/24contains your public IP. - You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact wording you are asking about so it can be corrected.