如何强制TCP数据包测试DNS?

mad*_*oda 5 dns bind dig

DNS 通常使用 UDP 数据包。然而,当响应大于一定大小时,它会切换到 TCP。

例如,如果我们在使用 DIG 或 NSLOOKUP 运行 DNS 查询命令时可以指定 TCP/UDP,那将非常有用。

有没有办法用 DIG 做到这一点?

小智 8

通过挖掘,您可以使用+tcp.

man dig说:

+[no]tcp
Use [do not use] TCP when querying name servers. The default behavior is to use UDP unless a type any or ixfr=N query is requested, in which case the default is TCP. AXFR queries always use TCP.

+[no]vc
Use [do not use] TCP when querying name servers. This alternate syntax to +[no]tcp is provided for backwards compatibility. The "vc" stands for "virtual circuit".
Run Code Online (Sandbox Code Playgroud)

因此,+tcp和 都+vc做你想做的事,但+tcp更清楚你想要做什么。

使用 dig myself 并使用 Wireshark 跟踪流量,我发现它dig google.com @8.8.8.8使用 UDP 并dig google.com @8.8.8.8 +tcp使用 TCP。


use*_*686 6

旧工具将此称为“虚拟电路”(vc) 模式:

dig google.com @8.8.8.8 +vc

nslookup -vc google.com 8.8.8.8
Run Code Online (Sandbox Code Playgroud)

Windows nslookup(交互模式):

nslookup> set vc
Run Code Online (Sandbox Code Playgroud)