A DNS query is a message sent from the client to the DNS server. DNS servers reply to these questions with answers. Servers may also reply with their own information if a DNS query contains multiple questions.

DNS Query Types

The DNS server that is replying to the request can follow one of three different DNS query types.

Non-recursive queries

In a non-recursive query, the DNS server holds the answer for the requested hostname and returns it. After the DNS server receives the answers, it will return them from its own cache or database. Instead of returning an empty response, the DNS server will respond with an empty response if it cannot locate information about the requested hostname.

Queries that recurse

When a DNS server or resolve is queried recursively, it is told to answer the send questions. Servers serving as authoritative servers for this domain should respond normally. The server, however, should perform a recursive query to resolve the domain name itself if it is not an authoritative server for the domain.

The iterative query

When DNS client requests an iterative DNS query, the server tries to answer the request as best as it can. In the event that the DNS server is the authoritative server or has information about the request in its cache, it will respond to the client with an answer. DNS servers, however, may refer users to other DNS servers if they cannot determine a response.

The Types of DNS Query Records

It is possible to retrieve different pieces of information from the nameservers using over 45 different queries and answers. As a result, the server returns so-called DNS records as answers. Most domains typically use only 9 out of the 45+ query types. The following are listed:

- A Record

An A record maps the requested hostname to its IPv4 address. In this way, the browser can translate a domain name and route it to the appropriate server.

- AAAA Record

In contrast to an A record, an AAAA record uses IPv6 addresses. Additionally, it allows the browser to determine which server to use based on the domain name.

- CNAME Record

The CNAME record is used as an alias to another hostname. A new request will be sent to the client to resolve the returned alias into an A or AAAA record. It is also possible for the server to include this record within the response.

- MX Record

MX records specify the hostname of SMTP email servers for a domain. Incoming emails for this domain are then routed by email services using this information.

- TXT Record

Text records are used for storing human-readable or machine-readable text. Various purposes can be served by this, including verification, authentication, or passing of information.

- NS Record

The NS record, also known as the Name Server record, contains the information about the nameservers responsible for providing DNS information for the domain in question, such as ns1.doman.com.

- PTR Record

Reverse-lookup pointers are used to map IP addresses to fully qualified hostnames with PTR records. In reverse DNS lookups, this information is used.

- SRV Record

SRV stands for Service Location, a record used for other communication protocols, similar to MX records.

- SOA Record

A domain name zone's SOA record serves as an administrative record. It indicates the current domain's Authoritative Name Server, contact details, serial number, and any DNS changes. A DNS refresh interval for this domain is also hints to the resolver.

How Is a DNS Query Structured?

The DNS query consists of multiple parts, as illustrated in the diagram below. DNS packets are formatted the same way.

How Is a DNS Query Structured

How Does a DNS Query Work?

Headers provide information about the packet length, client capabilities, and number of questions in the query. Next, the packet contains the encoded queries and any additional information that was sent by the client.

DNS queries typically contain between 50 and 100 bytes of data.

How Does DNS Communicate With Its Servers?

DNS queries are typically sent as UDP packets by the client to the server. As UDP is generally considered to be faster than other standard network protocols, this is primarily for performance reasons. Nevertheless, the client might retry the connection via a TCP connection if the server does not reply for whatever reason.

In cases where DNS responses do not fit into UDP packets, a server may request the client to resend the query using TCP. As a result, the server will be able to return long responses over the connection.

DoH (DNS over HTTPS) is a new protocol that uses the HTTP protocol to resolve DNS records. In order to improve hostname resolution security, encryption was used. AgileCDN provides free SSL certificate to safeguard your website.