单个 DNS 响应中可以容纳多少条 A 记录? [英] How many A records can fit in a single DNS response?

查看:47
本文介绍了单个 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.

推荐答案

保证支持的最大 DNS 消息大小为 512 字节.

The largest guaranteed supported DNS message size is 512 bytes.

其中 12 个被标头用完(参见 RFC 1035 的 §4.1.1).

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:

  • 域名(有线格式)
  • QTYPEQCLASS 各两个字节
  • 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.

假设使用了标签压缩(第 4.1.4 节),每个 A 记录将需要:

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

  • 压缩指针的两个字节
  • TYPECLASS 各两个字节
  • TTL 的四个字节
  • RDLENGTH 的两个字节
  • A 记录数据本身的四个字节
  • 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

即每个 A 记录 16 个字节(第 4.1.3 节).

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

如果可能,您还应该权威部分中包含您的 NS 记录.

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

考虑到所有这些,您可能会将大约 25 条记录压缩到一个响应中.

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

这篇关于单个 DNS 响应中可以容纳多少条 A 记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆