← Back to dashboard
cloudflare-1-1-1-1domainsfreshReader view (for NotebookLM)

Cloudflare 1.1.1.1 (DNS Resolver) Integration Guide

What is 1.1.1.1?

The real model

Keyless DoH at cloudflare-dns.com/dns-query. Read Status and Comment, never just response.ok.

GET /dns-query?name=x&type=TXT with accept: application/dns-json. DNS failures are HTTP 200: NXDOMAIN is Status 3 and a DNSSEC failure is Status 2. NOERROR can still mean no records (no Answer key) or a Families block (0.0.0.0 with EDE 16 or 17). Filter Answer by numeric type to drop CNAME hops, and unquote TXT data before comparing. The JSON format has no RFC and had breaking changes in 2026, so use application/dns-message with dns-packet when a wrong parse matters. There is no SLA, so use a timeout and a second resolver on any customer path. For codeAmani this suits checking customer DNS during onboarding, and Android Private DNS suits staff phones on Kenyan projects.

Six 1.1.1.1 primitives

One resolver, reached through different transports and filter levels. Pick by who is asking and what they need to hide or block.

Text
 ██╗   ██╗   ██╗   ██╗
███║  ███║  ███║  ███║
╚██║  ╚██║  ╚██║  ╚██║
 ██║   ██║   ██║   ██║
 ██║██╗██║██╗██║██╗██║
 ╚═╝╚═╝╚═╝╚═╝╚═╝╚═╝╚═╝

Cloudflare 1.1.1.1 (DNS Resolver) Integration Guide

Focus: query DNS from application code over HTTPS, read the results correctly, and choose the right resolver variant for a device or network. This is the sub-guide to cloudflare/. For DNS records you publish, see porkbun/ for registrar DNS and the Cloudflare DNS docs for zones hosted there.

Overview

1.1.1.1 is a recursive resolver: it looks up names on behalf of clients. It is not authoritative DNS, so it does not host your records. It is free on all plans, needs no account or API key, and Cloudflare operates it in partnership with APNIC.

There are two ways codeAmani uses it:

  • From code: the DNS-over-HTTPS (DoH) API, for example to confirm that a customer added the TXT or CNAME record you asked for.
  • On a device or network: set it as the resolver, optionally with Families filtering or with encryption through Android Private DNS.
VariantIPv4IPv6DoH endpointDoT hostname
Standard (unfiltered)1.1.1.1, 1.0.0.12606:4700:4700::1111, ::1001https://cloudflare-dns.com/dns-queryone.one.one.one
Families: malware1.1.1.2, 1.0.0.22606:4700:4700::1112, ::1002https://security.cloudflare-dns.com/dns-querysecurity.cloudflare-dns.com
Families: malware + adult1.1.1.3, 1.0.0.32606:4700:4700::1113, ::1003https://family.cloudflare-dns.com/dns-queryfamily.cloudflare-dns.com

Full tables and error codes are in reference/endpoints-and-codes.md.

Should you use it here?

NeedUse
Check a DNS record from a server or script1.1.1.1 DoH
Encrypt DNS on a phone or laptop1.1.1.1 via Private DNS, or the 1.1.1.1 app
Block malware or adult content on a shared network1.1.1.1 for Families
Encrypt all device traffic, not only DNSWARP client
An SLA, dedicated support, custom filtering, or analyticsCloudflare Gateway (Zero Trust)
See what your nameserver currently publishesQuery the authoritative nameserver (recipe)

Official Documentation

Quickstart: query from code

No key or SDK is needed. The accept header is required: without it, the endpoint answers 400.

Bash
curl -H "accept: application/dns-json" "https://cloudflare-dns.com/dns-query?name=example.com&type=A"
JSON
{
  "Status": 0, "TC": false, "RD": true, "RA": true, "AD": true, "CD": false,
  "Question": [{ "name": "example.com", "type": 1 }],
  "Answer": [{ "name": "example.com", "type": 1, "TTL": 121, "data": "172.66.147.243" }]
}

Use the typed client instead of parsing this by hand. examples/doh-json.ts handles the traps below and has no dependencies:

TypeScript
import { resolveDoh } from "./doh-json";

const { outcome, values } = await resolveDoh("_dmarc.codeamanilabs.org", "TXT");
if (outcome === "answer") {
  // values are unquoted and contain TXT records only
}

For binary RFC 8484 queries, use examples/doh-wire.ts:

Bash
npm install dns-packet
npm install -D @types/dns-packet

Choosing JSON or wireformat

JSON (application/dns-json)Wireformat (application/dns-message)
MethodsGET onlyGET or POST
DependenciesNonedns-packet or similar
StabilityNo RFC. Cloudflare warns behaviour may changeRFC 1035 message format
Use forScripts, dashboards, non-critical checksAnything where a wrong parse has a cost

Cloudflare recommends wireformat for critical use. Its 2026-07-28 JSON change altered the data format for CAA, HTTPS, SVCB, TLSA and SSHFP records and for DNSSEC algorithm identifiers. Responses could use either format during the rollout, so don't parse those data strings in anything that matters.

Reading responses correctly

These are the mistakes this API invites. Unless marked documented, each was observed against the live resolver on 2026-11-04.

TrapWhat actually happensDo this
Trusting response.okDNS failures are HTTP 200: NXDOMAIN is Status: 3, a DNSSEC failure is Status: 2, and ANY is Status: 4Branch on Status. HTTP errors only mean a bad request or a timeout (400, 413, 415, 504, documented)
Status === 0 means the record existsA name with no record of that type is Status: 0 with no Answer keyTreat a missing Answer as NODATA
Treating 0.0.0.0 as a real answerA Families block is Status: 0 with 0.0.0.0 (A) or :: (AAAA)Check Comment and the address. Malware blocks say EDE(16): Censored, adult blocks say EDE(17): Filtered. Neither code is in Cloudflare's EDE table, so also match the sinkhole addresses
Reading Answer[0].dataAnswer includes CNAME hops, so index 0 may be a hostnameFilter by the numeric type you asked for
Comparing TXT values directlyTXT data is wrapped in quotes, and long values can be split into several quoted stringsUnquote and join first (unquoteTxt in the example)
Using NXDOMAIN to prove a name is freeNonexistent names in the Cloudflare-hosted zones we tested returned NOERROR with no Answer, not NXDOMAINTreat nxdomain and nodata both as "no record". Never use them to decide a domain is available
Asking for ANYNot supported: documented as NOTIMPL, returned as Status: 4Query each type
Sending several questions in one requestEach DoH request carries one question (documented)Send parallel requests over HTTP/2

Connect a device or network

Android 9 and later (Private DNS): go to Settings > Network & internet > Advanced > Private DNS, choose Private DNS provider hostname, and enter one.one.one.one or one of the Families hostnames. This applies on every network, including cellular. Menu names vary by manufacturer.

Other devices: set the IPv4 and IPv6 addresses from the table above, always in pairs so there is a fallback. Each platform's steps are under Set up.

Browsers: Chrome, Edge, Firefox and Brave all offer Cloudflare in their secure DNS settings. Check the result at https://one.one.one.one/help, where Using DNS over HTTPS (DoH) should show Yes.

IPv6-only networks with NAT64: use the DNS64 addresses 2606:4700:4700::64 and 2606:4700:4700::6400. Only use them on such a network, because a synthesized AAAA record can't carry a valid DNSSEC signature.

To confirm filtering works, open the test pages. https://malware.testcategory.com/ should fail to load on both Families tiers, and https://nudity.testcategory.com/ should fail only on the malware + adult tier.

Encryption options

ProtocolPortReach it atNote
DoH443https://cloudflare-dns.com/dns-queryBlends in with HTTPS traffic. HTTP/2 is the recommended minimum. TLS 1.2 and 1.3
DoT853one.one.one.one, 1.1.1.1A dedicated port, so networks can block it. Used by Android Private DNS. TLS 1.2 and 1.3
ODoH443Target: odoh.cloudflare-dns.com, via a proxySplits your IP from your query across two parties. RFC 9230 is experimental, and you need a client such as dnscrypt-proxy
Tor-Hidden serviceSee DNS over Tor

Debugging

Bash
# Which Cloudflare data center answered?
dig +short CHAOS TXT id.server @1.1.1.1

# Compare resolvers: if only one differs, suspect its cache or the zone's nameservers
dig example.com @1.1.1.1
dig example.com @8.8.8.8

# Read the EDE reason for a failure
dig @1.1.1.1 dnssec-failed.org A

# Test DoT
kdig +tls @1.1.1.1 id.server CH TXT

On Windows, use nslookup -class=chaos -type=txt id.server 1.1.1.1.

  • Stale answer after a record change: clear the entry at https://one.one.one.one/purge-cache/, or wait out the TTL.
  • Traceroute to 1.1.1.1 dies at the first hop: Cloudflare documents that some routers have a hardcoded route for 1.1.1.1. This usually means a router problem, not an outage.
  • whoami.cloudflare.com output contains your IP: check before pasting it into a report.

codeAmani notes

  • Secrets: there are none. The API is keyless, so no environment variables or Hazina entries are needed. Never add an Authorization header to these calls.
  • Production dependency: there is no SLA, and dedicated technical support is limited. Don't let a request path fail because a lookup failed. Give it a timeout, a second resolver, and a "try again later" state. If a product needs a contractual guarantee, use Gateway.
  • User input: names often come from customers, for example during custom-domain onboarding. Validate them before querying (isQueryableHostname), and only pass the name through URLSearchParams.
  • Personal data: queries are logged. Cloudflare doesn't keep source IPs in non-volatile storage (apart from sampled packets from at most 0.05% of traffic) and deletes resolver logs within 25 hours, but queryName is a logged field and anonymized data is shared with APNIC. Don't put a user ID, email address or phone number in a queried name.
  • Rate limits: normal use shouldn't hit any. High-rate traffic from one IP and repeated uncacheable answers such as SERVFAIL can be limited, so cache results and back off.
  • Workers: outbound connect() sockets to Cloudflare IP ranges are blocked, so DoT to 1.1.1.1 won't work from a Worker. Use fetch with DoH, and test it, because this repo has only run these examples on Node.
  • Kenya-targeted projects: most users are on Android, so Private DNS with one.one.one.one is the simplest device hardening, and the setting is on the device, so an app can't set it. Keep this to staff phones and shop devices, and don't make a customer change DNS to complete a checkout. Before recommending it for a network, confirm the serving location by running curl https://1.1.1.1/cdn-cgi/trace on that network and reading colo.
  • Shared networks: Families suits school or clinic guest Wi-Fi, but it doesn't replace access control. Miscategorized domains are reported through the categorization feedback form.
  • AI routing: not applicable, because the resolver makes no model calls.