DNS message Format

Source: Internet
Author: User
Tags 0xc0 mail exchange

Message type

The DNS message consists of three types:

    • Request
    • Response
    • Update

The request and response are defined in the original standard, and the update is defined in RFC 2136.

DNS Common message Format

The DNS generic message format is as follows:

DNS message header

The DNS message header contains the following fields:

Field name Description
Transaction ID 16 bits, which identifies the DNS interaction once. Generated by the requester side and returned by the response to correspond the response message to the request message
Flags: 16 bits, containing various tokens, the tags are defined as follows:
Request/response 1-bit, 0 indicates the request, and 1 indicates a response
Operation code 4-bit, indicating opcode, 0x0 indicates query
Authoritative answer 1-bit, which indicates that the responder is the authoritative name server for the domain name
Truncation Truncation flag bit, 1-bit, 1 indicates response exceeds 512 bytes, has been truncated
Recursion desired 1-bit, indicating recursive query
Recursion available 1-bit, 1 indicates response value can handle recursive query
Reserved 3-bit, reserved field, 0
Return Code 4 bit, return code. 0 indicates a successful response, 0x3 indicates a domain name error, the domain name does not exist on the authoritative name server
Question Resource Record Count 16 bits, indicating the number of problems
Answer Resource Record Count 16-bit, indicating the number of answers
Authority Resource Record Count 16 bits, indicating the number of authoritative resource records
Additional Resource Record Count 16 bits, indicating the number of additional resource records
Question Field

This field represents the domain name of the query and contains the following three fields:

    • Question Name: Query name, consisting of a set of labels, in length-value format, 1 bytes for length, trailing data (that is, label). For example, the domain name www.baidu.com, represented as 0x03www0x05baidu0x03com, where the hexadecimal number represents the length.
    • Question type:16 bit, which represents the query type, has the following types:
      • 0x01 Host (A) record
      • 0x02 Name Server (NS) record
      • 0x05 Alias (CNAME) record
      • 0x0C Reverse-lookup (PTR) record
      • 0x0F Mail Exchange (MX) record
      • 0x21 Service (SRV) record
      • 0xFB Incremental zone Transfer (IXFR) record
      • 0xFC Standard zone transfer (AXFR) record
      • 0xFF All records
    • Question class: Represents the Query classes
DNS resource records

The answer, authorization, and additional information fields are in the resource record (Resource record) format, defined as follows:

Field name Description
Resource Record Name The DNS domain name, which is in the same format as the query name in the Problem field, but in order to save data, if the same name appears before, the value here is the location of the DNS start data in the same name relative to the message. If the query name for the question is www.baidu.com, the name of the resource record in the Answer field is the same, so its value is 0xc0 0x0c (0xc0 represents the reference, and 0x0c represents the location of the query name relative to the DNS start data is 12)
Resource Record Type 16 bit, resource record type, same as query type in question field
Resource Record Class 16-bit, resource record class (IN:0X0001)
Time-to-live 32-bit, TTL
Resource Data Length 16 Bits, resource data length
Resource Data Resource data

DNS message Format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.