「DNS」- 报文格式



两种报文格式相同,都有:一个头部 + 四个部分


A header field contols the content of these four sections.

(16 bit)Identification, used to match responses with queries

(16 bit)Flags,

QR, Indicates if the message is a query (0) or a reply (1)

OPCODE, The type can be QUERY (standard query, 0), IQUERY (inverse query, 1), or STATUS (server status request, 2)

AA, Authoritative Answer, in a response, indicates if the DNS server is authoritative for the queried hostname

TC, TrunCation, indicates that this message was truncated due to excessive length

RD, Recursion Desired , indicates if the client means a recursive query

RA, Recursion Available, in a response, indicates if the replying DNS server supports recursion

Z, Zero, reserved for future use

RCODE, Response code, can be NOERROR (0), FORMERR(1, Format error), SERVFAIL (2), NXDOMAIN (3, Non existent domain), etc.

(16 bit)Number of questions,

(16 bit)Number of answers,

(16 bit)Number of authority resource records (RRs),

(16 bit)Number of additional RRs

question, answer, authority, an additional space


NAME Name of the requested resource

TYPE Type of RR (A, AAAA, MX, TXT, etc.)

CLASS Class code



an additional space