π DNS query and response message format (10 MCQs)
The Twelve-Byte DNS Message Header
A DNS message contains a fixed 12-byte header followed by up to four logical sections: Question, Answer, Authority and Additional. The same general format supports queries and responses. Header fields identify the transaction, indicate message type and status, and give counts describing the records or questions present in each section. Its distributed structure avoids reliance on one central database for every Internet name worldwide.
Question, Answer, Authority and Additional Sections
The header contains a 16-bit identifier, flags and four 16-bit count fields. Flags include QR, opcode, AA, TC, RD, RA, reserved bits and response code. The Question section specifies the queried name, type and class; resource-record sections carry answers, authority information and useful additional data. Record types let different network services publish information in a common naming system.
Flags, Counts and Resource Record Encoding
A client creates a query with QR set to zero, places a question in the Question section and sends it to a DNS server. The server matches the transaction, processes the name and type, then returns a response with QR set to one. It populates answer or referral data and sets appropriate flags and counts.
Reading a DNS Query for an A Record
A client queries for the A record of www.example.com. The header contains a transaction identifier, RD may request recursion, and QDCOUNT is one. The Question section carries the name, QTYPE A and QCLASS IN. A successful response can place the IPv4 address record in the Answer section and report NOERROR.
How a Response Carries Answers and Referrals
The Answer section contains records answering the question. The Authority section can identify authoritative servers or include relevant zone information, while Additional may provide related address data. TC indicates truncation, AA marks an authoritative answer, and RCODE reports outcomes such as success or name error. This division supports scalable administration while keeping naming separate from packet forwarding.
Misinterpreting DNS Header Fields
'The DNS identifier is the queried IP address' is false because it is a transaction value used to match request and response. 'QDCOUNT gives the number of answer records' confuses sections; it counts questions. 'The Authority section always contains the root servers' is incorrect because its contents depend on the response and delegation context.
Analyzing DNS Message Sections and Flags
Practice locating the 12-byte header, identifying QR, RD, RA, AA and TC, and interpreting the four count fields. Trace QNAME, QTYPE and QCLASS in the Question section, then locate returned records in Answer, Authority or Additional. Distinguish NOERROR from NXDOMAIN and a truncated UDP response from an ordinary complete answer.
DNS Message Header and Section Terms
- Transaction ID - Matches a DNS reply to its query.
- QR - Distinguishes query from response.
- QDCOUNT - Counts entries in the Question section.
- RCODE - Reports the DNS response result.
- AA - Marks an authoritative answer.
- TC - Signals a truncated DNS message.
π All DNS query and response message format MCQs
Q1. In a standard DNS message header, which field specifies the number of resource records returned in the answer section?
π Explanation: The DNS header includes a 16βbit Answer RRs field that tells the resolver how many resource records appear in the answer section. This count is separate from the Question Count, Authority Count, and Additional Count fields, each of which tracks a different part of the message.
Q2. When a DNS response has the TC (truncated) flag set, what is the most appropriate action for the resolver?
π Explanation: The TC flag indicates that the response was cut short because it exceeded the UDP payload limit. The resolver should therefore reβissue the same query using TCP, which can carry the full message without truncation, ensuring complete data retrieval.
Q3. Which statement correctly contrasts the QR flag usage in a DNS query versus a DNS response?
π Explanation: The QR (Query/Response) flag distinguishes a message's purpose: it is cleared (0) for a query sent by a client and set (1) for a response generated by a server. This binary distinction allows receivers to quickly interpret the direction of the message.
Q4. A resolver wants the authoritative server to perform recursion. Which flag must be set, and what value should the RD bit have in the query header?
π Explanation: The Recursion Desired (RD) flag tells the server that the client wishes the server to pursue recursive resolution on its behalf. Setting RD to 1 in the query header signals this intent, while the Recursion Available (RA) flag is set by the server in its response.
Q5. If a DNS response returns an RCODE of 3 (NXDOMAIN), what can the resolver infer about the queried domain name?
π Explanation: An RCODE of 3 means NXDOMAIN, indicating that the queried name does not exist in the DNS namespace. The resolver can safely conclude that the domain name is invalid and should not be retried without modification.
Q6. Suppose a resolver advertises an EDNS0 UDP payload size of bytes, but the authoritative server sends a response of bytes. What is the likely outcome?
π Explanation: When a response exceeds the advertised UDP payload, the server sets the TC (truncated) flag, indicating that the full answer is larger than can be sent in a single UDP packet. The resolver then typically retries the query over TCP to obtain the complete data.
Q7. How does the TTL field in each resource record influence a resolverβs caching strategy when multiple responses with differing TTLs are received for the same query?
π Explanation: Each RR is cached with its own TTL, and the overall cache entry expires when the shortest remaining TTL among the set of records elapses. This ensures that no stale data persists longer than the leastβfresh record, preserving consistency across cached answers.
Q8. A resolver receives a DNS response whose transaction ID does not match the ID of any outstanding query. Assuming no network attacks, what is the most plausible explanation?
π Explanation: The most likely scenario is that the response belongs to an earlier query that was delayed in the network. Because the resolver had already reused the transaction ID for a newer query, the unexpected ID appears mismatched, reflecting normal outβofβorder delivery.
Q9. An attacker sends a DNS query of size bytes to an open resolver that supports EDNS0 with a UDP payload size of bytes, requesting a DNSSECβsigned response. If the response is bytes, calculate the amplification factor and explain why this poses a security risk.
π Explanation: The amplification factor is the response size divided by the query size: . Such a large multiplier enables attackers to flood a victim with far more traffic than they send, turning modest queries into massive responses and facilitating DDoS attacks.
Q10. When constructing a DNS response that includes DNSSEC RRSIG records, which sections must be present and how do they interrelate to ensure authenticity?
π Explanation: A DNSSECβenabled response must contain the original RRsets (Answer, Authority, and sometimes Additional) together with corresponding RRSIG records that cryptographically cover each RRset. The RRSIGs provide signatures that validators can verify using the appropriate DNSKEY, establishing the integrity and authenticity of the entire response.