DNS over HTTPS (DoH)
-
Cloudflare: DNS over HTTPS链接developers.cloudflare.com/1.1.1.1/dns-over-httpsCloudflare: DNS over HTTPS · Using JSON · Google Public DNS: DoH JSON API · Wikipedia: DNS over HTTPS · JSON · 只支持 GET,查询编码在 URL;Cloudflare 需要笔记:DNS over HTTPS (DoH)
-
JSON
- 只支持 GET,查询编码在 URL;Cloudflare 需要
Accept: application/dns-json - 没有 RFC,Cloudflare 沿用 Google 的 schema,各家行为可能不同;严格场景用 wire format
- 参数:
name(必填)、type(默认A)、do(DNSSEC)、cd(关闭校验)
- 只支持 GET,查询编码在 URL;Cloudflare 需要
-
wire format - RFC 8484,
application/dns-message- GET:
?dns=<base64url DNS 报文> - POST:body 为二进制报文,必须设置
Content-Type: application/dns-message,否则返回 415
- GET:
Status Codes
- 400 DNS query not specified or too small.
- 413 DNS query is larger than maximum allowed DNS message size.
- 415 Unsupported content type.
- 504 Resolver timeout while waiting for the query response.
Examples
# Cloudflare JSON
curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=example.com&type=AAAA'
curl -H 'accept: application/dns-json' 'https://1.1.1.1/dns-query?name=example.com&type=A&do=1'
# Google JSON
curl 'https://dns.google/resolve?name=example.com&type=AAAA'
# ct=application/x-javascript 显式请求 JSON;ct=application/dns-message 则返回二进制 DNS 报文
curl 'https://dns.google/resolve?name=example.com&type=A&ct=application/x-javascript'{
"Status": 0,
"TC": false,
"RD": true,
"RA": true,
"AD": true,
"CD": false,
"Question": [{ "name": "example.com.", "type": 28 }],
"Answer": [{ "name": "example.com.", "type": 28, "TTL": 1726, "data": "2606:2800:220:1:248:1893:25c8:1946" }]
}Status是 DNS RCODE:0 NOERROR,2 SERVFAIL,3 NXDOMAINtype为数字:1 A,5 CNAME,28 AAAA
关联信息
反向链接、本文链接的其他页面和外部资料。
参考资料
Wikipedia1 条
- DNS over HTTPSWikipedia:DNS over HTTPS
其他外链3 条
- developers.cloudflare.com/1.1.1.1/dns-over-httpsdevelopers.cloudflare.com/1.1.1.1/dns-over-https
- developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-jsondevelopers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json
- developers.google.com/speed/public-dns/docs/doh/jsondevelopers.google.com/speed/public-dns/docs/doh/json