单个 DNS 响应中可以容纳多少条 A 记录?
DNS 响应的大小限制是多少?例如,单个 DNS 响应中可以存在多少个“A”资源记录? DNS 响应仍应可缓存。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
保证支持的最大 DNS 消息大小为 512 字节。
其中,12 个被标头用完(请参阅 RFC 1035)。
接下来出现的是问题部分,但长度可变 - 具体来说,它将是:
因此,您的域名越长,留给答案的空间就越少。
假设使用标签压缩(第 4.1.4 节),每个
A
记录将需要:,即每个 A 记录 16 个字节( §4.1.3)。
如果可能,您还应该在权限部分中包含您的 NS 记录。
考虑到所有这些,您可能会将大约 25 条记录压缩到一个响应中。
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:
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: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.
根据此 RFC,该限制基于UDP 消息大小限制,即 512 个八位位组。 EDNS 标准支持协商响应,响应大小几乎不受限制,但在撰写本文时(2011 年 3 月),只有 65% 的客户端支持它(这意味着您不能真正依赖它)
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)