DNS over HTTPS (DoH) enhances DNS resolution by encrypting queries and responses, improving privacy and security. Understanding the underlying query format is crucial for developers, network administrators, and anyone interested in the technical details of DoH. This guide provides a comprehensive overview of the DoH query format, covering its structure, key components, and practical implications.
Unlike traditional DNS which uses UDP or TCP, DoH leverages HTTPS, specifically using the POST method. This means DoH queries are sent as HTTP POST requests to a specified DoH resolver's endpoint. The body of the POST request contains the DNS query in a structured format, typically JSON. Let's break down the key aspects:
The HTTP request itself follows standard HTTP/1.1 or HTTP/2 conventions. The essential components are:
https://dns.google/resolve). This URL is crucial and determines which resolver will handle the query.Content-Type: application/dns-message are essential. This header indicates that the request body contains a DNS message.The JSON payload within the POST request body defines the DNS query. The structure is standardized to ensure interoperability across different DoH implementations. Key fields include:
edns_client_subnet: Optional field providing the client's IP address. This aids in geolocation and other services.ct: (Optional) This parameter allows for specifying the Client Trust Option, which can be used to secure the DoH communication even further.name: The DNS query name (e.g., www.example.com). This is the domain name being looked up.type: The DNS record type (e.g., A, AAAA, CNAME). This specifies the kind of information being requested.dnssec: (Optional) This flag allows for indicating that DNSSEC validation is requested.do: (Optional) This flag indicates whether DNS over TLS (DoT) is in use. While generally implicit with DoH, it's beneficial in specific circumstances.cd: (Optional) This flag enables checking for DNSSEC and flags if a DNSSEC validation failure occurs.
{
"name": "www.example.com",
"type": "A",
"edns_client_subnet": {
"address": "192.0.2.1",
"family": "v4"
}
}
The DoH response is also sent as a JSON object within an HTTP response. The response structure generally mirrors the request, with additional fields containing the DNS record information. This typically includes an Answer section containing the IP address or other data requested. Error codes are also conveyed within the JSON response to facilitate proper error handling.
Understanding the DoH query format is essential for several reasons:
This guide provides a comprehensive overview of the DoH query format. Further research into specific DoH resolver implementations and related specifications will provide even deeper insight.