How many A records can fit in a single DNS response?

烈酒焚心 提交于 2021-02-05 08:27:29

问题


What are the size limits on DNS responses? For instance how many 'A' resource records can be present in a single DNS response? The DNS response should still be cache-able.


回答1:


The largest guaranteed supported DNS message size is 512 bytes.

Of those, 12 are used up by the header (see §4.1.1 of RFC 1035).

The Question Section appears next, but is of variable length - specifically it'll be:

  • the domain name (in wire format)
  • two bytes each for QTYPE and QCLASS

Hence the longer your domain name is, the less room you have left over for answers.

Assuming that label compression is used (§4.1.4), each A record will require:

  • two bytes for the compression pointer
  • two bytes each for TYPE and CLASS
  • four bytes for the TTL
  • two bytes for the RDLENGTH
  • four bytes for the A record data itself

i.e. 16 bytes for each A record (§4.1.3).

You should if possible also include your NS records in the Authority Section.

Given all that, you might squeeze around 25 records into one response.




回答2:


According to this RFC, the limit is based on the UDP message size limit, which is 512 octets. The EDNS standard supports a negotiated response with a virtually unlimited response size, but at the time of that writing (March 2011), only 65% of clients supported it (which means you can't really rely on it)



来源:https://stackoverflow.com/questions/6794926/how-many-a-records-can-fit-in-a-single-dns-response

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!