domain-name-system – DNS协议如何从UDP切换到TCP?

前端之家收集整理的这篇文章主要介绍了domain-name-system – DNS协议如何从UDP切换到TCP?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在有人要求之前:我见过 When do DNS queries use TCP instead of UDP?并且它没有回答我的问题.

我一直听到的是“如果答案太长,DNS将使用TCP”.这并没有解释它是如何发生的.

所以情况就是这样:DNS客户端要求使用UDP解析记录. UDP的记录太长了:

>具有特定操作码的服务器答案,让客户端切换到TCP
>服务器根本没有应答,客户端重新尝试TCP
>服务器打开到客户端的TCP连接(愚蠢,如果你算NAT,但谁知道?)
>客户端不知何故(?)’知道’给定的查询应该通过TCP运行,所以它首先不打扰UDP
> DNS pixies在需要时神奇地将UDP转换为TCP

我一直在网上寻找答案,但是有很多噪音(见上文),我似乎无法为此写出正确的Google查询(也不能在RFC中找到相关信息) .

解决方法

客户端事先并不知道响应会太大,因此它将通过UDP查询服务器.
服务器将通过UDP进行响应,并尽可能包含并设置截断的标题位(“TC” http://www.networksorcery.com/enp/protocol/dns.htm).
然后,客户端可以通过TCP重新发送请求并获得完整响应.

另见:https://tools.ietf.org/html/rfc5966

In the absence of EDNS0 (Extension Mechanisms for DNS 0) (see
below),the normal behavIoUr of any DNS server needing to send a
UDP response that would exceed the 512-byte limit is for the server
to truncate the response so that it fits within that limit and then
set the TC flag in the response header. When the client receives
such a response,it takes the TC flag as an indication that it
should retry over TCP instead.

并且:https://www.ietf.org/rfc/rfc2181.txt

正如评论中所提到的,DNS区域传输当然总是使用TCP.

原文链接:https://www.f2er.com/html/230025.html

猜你在找的HTML相关文章