start page | rating of books | rating of authors | reviews | copyrights

DNS & BIND

DNS & BINDSearch this book
Previous: A.1 Master File Format Appendix A
DNS Message Format and Resource Records
Next: A.3 Header Section Format
 

A.2 DNS Message

In order to write programs that parse DNS packets, you need to understand the message format. DNS queries and responses are most often contained within UDP packets. Each message is fully contained within a UDP packet. If the query and response are sent over TCP, then they are prefixed with a two-byte value indicating the length of the query or response, excluding the two-byte length. The format and content of the DNS packet are as follows.

A.2.1 Format

(From RFC 1035, page 25)

All communications inside of the domain protocol are carried in a single format called a message. The top level format of message is divided into 5 sections (some of which are empty in certain cases) shown below:

    +---------------------+     |        Header       |     +---------------------+     |       Question      | the question for the name server     +---------------------+     |        Answer       | RRs answering the question     +---------------------+     |      Authority      | RRs pointing toward an authority     +---------------------+     |      Additional     | RRs holding additional information     +---------------------+

The header section is always present. The header includes fields that specify which of the remaining sections are present, and also specify whether the message is a query or a response, a standard query or some other opcode, etc.

The names of the sections after the header are derived from their use in standard queries. The question section contains fields that describe a question to a name server. These fields are a query type (QTYPE), a query class (QCLASS), and a query domain name (QNAME). The last three sections have the same format: a possibly empty list of concatenated resource records (RRs). The answer section contains RRs that answer the question; the authority section contains RRs that point toward an authoritative name server; the additional records section contains RRs which relate to the query, but are not strictly answers for the question.


Previous: A.1 Master File Format DNS & BIND Next: A.3 Header Section Format
A.1 Master File Format Book Index A.3 Header Section Format