A DNS query is a request message sent by a client to a DNS server asking for records matching a specific domain name, record type, and class, answered according to RFC 1035 specifications. The query initiates nearly every network connection and serves as a direct measure of DNS service demand, with volume analysis by record type, client, and response code revealing capacity needs and identifying misconfigurations. Monitoring query patterns—including spikes in NXDOMAIN responses, query floods, and truncated UDP responses—is critical for operational reliability and security, as unmonitored query traffic allows problems to surface only as user complaints rather than being proactively resolved.
How DNS query works
A DNS query carries a question made of a name, a record type and a class. The client sends it to a resolver, which either answers from its cache or works through the DNS hierarchy to find the answer.
- Build the question: The client forms a query with the domain name to look up, the record type (for example A, AAAA, MX or TXT) and the class, which is almost always IN for Internet.
- Send to a resolver: The client's stub resolver sends the query to a configured recursive resolver, usually over UDP on port 53.
- Check the cache: The recursive resolver returns a cached answer if it holds an unexpired one for the same name and type.
- Query authoritative servers: If there is no cached answer, the resolver sends iterative queries to root, top-level domain and authoritative servers until one gives the answer or an error.
- Return the response: The resolver sends the answer to the client and caches it for the time set by the record's time to live.
Queries normally use UDP, and the client retries over TCP when a response is truncated. The response code reports the outcome, such as no error or NXDOMAIN for a name that does not exist. Extensions such as EDNS and encrypted transports like DNS over TLS change how queries are carried, not what they ask.
Common DNS query issues
A large burst of queries, often for random names or from spoofed sources, can exhaust resolver CPU, sockets or upstream bandwidth. Symptoms are rising latency, SERVFAIL or timeouts, and a query rate far above the normal baseline.
A misconfigured client or application that ignores TTL and caching can send the same query many times per second. It shows up in logs as one client dominating the top-talker list for a single name.
A sudden rise in NXDOMAIN responses often traces to a broken application, a wrong search domain suffix or a stale configuration pointing at a removed name. Clients may also append several search suffixes, multiplying failed queries per lookup.
When an answer exceeds the size a client accepts over UDP, the server sets the truncation flag and the client must retry over TCP. Firewalls that block TCP port 53 cause intermittent failures for large responses such as those with DNSSEC data.
Clients configured with a public or stale resolver bypass internal DNS, so internal names fail to resolve or return different answers. This often appears after DHCP scope changes or on devices with hard-coded DNS settings.