πŸŽ“ BookMCQ
← Back to 26. Standard Client Server Protocols

πŸ“ 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.
3
Easy
4
Medium
3
Hard

πŸ“ 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?

A.Answer Count βœ…
B.Question Count
C.Authority Count
D.Additional Count
πŸ’‘ Difficulty: easy | βœ… Correct: A

πŸ“– 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?

A.Resend the query using UDP
B.Retry the query over TCP βœ…
C.Discard the response
D.Send an ICMP error message
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– 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?

A.QR is 0 in queries and 1 in responses βœ…
B.QR is 1 in queries and 0 in responses
C.QR is always 0
D.QR is always 1
πŸ’‘ Difficulty: easy | βœ… Correct: A

πŸ“– 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?

A.RD set to 0
B.RD set to 1 βœ…
C.RA set to 1
D.RA set to 0
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– 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?

A.The domain definitely does not exist βœ…
B.The domain exists but has no records
C.The server refused to answer
D.The response is malformed
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– 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 40964096 bytes, but the authoritative server sends a response of 45004500 bytes. What is the likely outcome?

A.The response is truncated and the TC flag is set βœ…
B.The server will switch to TCP automatically
C.The resolver will ignore the extra bytes
D.The response will be delivered over UDP without issue
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– 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?

A.Resolver uses the smallest TTL βœ…
B.Resolver uses the largest TTL
C.Resolver averages the TTLs
D.TTL is ignored for caching
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– 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?

A.The resolver reused an ID too quickly
B.The response is from a previous query still in transit βœ…
C.The server generated a random ID
D.The response was corrupted in transit
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– 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 6060 bytes to an open resolver that supports EDNS0 with a UDP payload size of 40964096 bytes, requesting a DNSSEC‑signed response. If the response is 4,0004{,}000 bytes, calculate the amplification factor and explain why this poses a security risk.

A.Amplification factor β‰ˆ 66.7 βœ…
B.Amplification factor β‰ˆ 40
C.Amplification factor β‰ˆ 100
D.Amplification factor β‰ˆ 20
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: The amplification factor is the response size divided by the query size: 4,000Γ·60β‰ˆ66.74{,}000 Γ· 60 β‰ˆ 66.7. 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?

A.Question and Answer sections only
B.Answer and Authority sections with matching RRSIG
C.Answer, Authority, and Additional sections with RRSIG covering each RRset βœ…
D.Only the Additional section is needed
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– 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.

πŸ”— Related Topics (MCQs)