DNS is a byte-structured question and answer format, not a magic name service. This lesson previews how a query message names a question before any answer appears.

highlighted = computed this step

Why DNS is a message

DNS turns a name into data by sending a structured message. The bytes say which question is being asked and how many answer records are present.

header bytes=12\text{header bytes}=12
Query header previewThe DNS query header is decoded from exact bytes.Query header preview96 bits / 12 bytes0x123401000001000000000000byte 0byte 1byte 2byte 300010010001101000000000100000000byte 4byte 5byte 6byte 700000000000000010000000000000000byte 8byte 9byte 10byte 1100000000000000000000000000000000id0x1234flags0x0100qdcount1ancount0nscount0arcount0

Preview the query parts

This query begins with a 12-byte header, then the name bytes, then the question type and class.

12 header bytes12\text{ header bytes}
Query header previewThe DNS query header is decoded from exact bytes.Query header preview96 bits / 12 bytes0x123401000001000000000000byte 0byte 1byte 2byte 300010010001101000000000100000000byte 4byte 5byte 6byte 700000000000000010000000000000000byte 8byte 9byte 10byte 1100000000000000000000000000000000id0x1234flags0x0100qdcount1ancount0nscount0arcount0

Why the count matters

The header says there is 1 question, so the following QNAME belongs to that one question section.

QDCOUNT=1\text{QDCOUNT}=1
Query header previewThe DNS query header is decoded from exact bytes.Query header preview96 bits / 12 bytes0x123401000001000000000000byte 0byte 1byte 2byte 300010010001101000000000100000000byte 4byte 5byte 6byte 700000000000000010000000000000000byte 8byte 9byte 10byte 1100000000000000000000000000000000id0x1234flags0x0100qdcount1ancount0nscount0arcount0

Summary

DNS is not magic here: it is a header plus encoded question bytes. Message structure and exact bytes only; resolution timing, caching, and UDP/TCP transport are not modeled here.

ID=0x1234\text{ID}=0x1234
Query header previewThe DNS query header is decoded from exact bytes.Query header preview96 bits / 12 bytes0x123401000001000000000000byte 0byte 1byte 2byte 300010010001101000000000100000000byte 4byte 5byte 6byte 700000000000000010000000000000000byte 8byte 9byte 10byte 1100000000000000000000000000000000id0x1234flags0x0100qdcount1ancount0nscount0arcount0