Windows 中执行反向 DNS 查找的命令行实用程序是什么?

ala*_*irs 285 domain-name-system windows ip command-line-interface reverse-dns

是否有内置的命令行工具可以在 Windows 中进行反向 DNS 查找?即,像<toolname> w.x.y.z => mycomputername

我试过了:

  • nslookup: 似乎只是向前查找。
  • host: 不存在
  • dig: 也不存在。

我通过搜索找到了“什么是反向 DNS 命令行实用程序? ”,但这是专门寻找 *nix 实用程序,而不是 Windows 实用程序。

Pet*_*ter 268

ping -a w.x.y.z
Run Code Online (Sandbox Code Playgroud)

如果反向查找区域已正确设置,则应从 IP 地址解析名称。如果反向查找区域没有记录条目,-a则只会 ping 没有名称。

  • 这*有效*,但它实际上是错误的工作工具。Ping 用于测量网络延迟,它执行名称(或 IP)查找,就像其主要目的的*副作用*。 (10认同)
  • 在 nslookup 中,您也可以尝试: set type=PTR &lt;enter&gt; wxyz &lt;enter&gt; (7认同)
  • @ Massimo - 鉴于原始问题的限制,您会建议什么?Ping 将解析 DNS 和 netbios 名称,如果您只需要一些快速的东西,这使它成为一个很好的第一个工具。 (4认同)
  • 这比 nslookup 更有效,因为冲突机器在另一个域上。非常感谢! (3认同)
  • ping 绝对不是适合这项工作的工具。如前所述,查找是一个副产品。 (2认同)
  • @Peter我认为具体来说,ping还有DNS以外的其他来源(例如netbios或hosts文件),这使得它成为一个非常糟糕的工具,因为如果用户试图测试反向DNS查找,它会默默地产生误导性的结果(问题要求什么)。 (2认同)

小智 137

nslookup <ip>
Run Code Online (Sandbox Code Playgroud)

做你正在寻找的。它会告诉您正在查询的服务器和结果。

例如:

c:\>nslookup 192.168.101.39
Server: dns1.local
Address: 192.168.101.24

Name: enigma.local
Address: 192.168.101.39
Run Code Online (Sandbox Code Playgroud)

  • 这失败并显示消息“&lt;DC&gt; 找不到 wxyz:不存在的域”,我不知道为什么。我尝试了@Peter 的回答,发现有冲突的机器在另一个域上。 (10认同)
  • 它失败了,因为 nslookup 只关心 DNS,而如果 DNS 不够用,Windows 中的名称可以并且将通过其他方式解析。 (9认同)

abs*_*ask 86

“ping”的问题在于它不是严格意义上的名称服务器查找工具(如 nslookup)——例如,如果您 p​​ing 一个主机名,它可以通过多种方法解析为 IP 地址:DNS 查找、主机文件查找、 WINS(上帝保佑)或 NetBIOS 广播。它还可以返回可能过时的缓存结果。

尝试这些方法的顺序取决于客户端的 TCP/IP 配置和节点类型标志:

  • B节点(1):广播
  • P 节点 (2):对等节点(仅限 WINS)
  • M-节点(4):混合(广播,然后WINS)
  • H-节点(8):混合(WINS,然后广播)

查看当前计算机的节点类型:

C:\>ipconfig /all | find "Node Type"
Node Type . . . . . . . . . . . . : Hybrid
Run Code Online (Sandbox Code Playgroud)

如果解决方法无关紧要,请使用

ping -a w.x.y.z
Run Code Online (Sandbox Code Playgroud)

或者

nslookup w.x.y.z
Run Code Online (Sandbox Code Playgroud)

如你所愿。如果您需要确保查询 DNS 服务器的名称正确,请使用nslookup

也可以看看


小智 38

使用带有“-type=ptr”参数的 NSLOOKUP 查询 IP 地址,语法:

nslookup -type=ptr 1.2.3.4
Run Code Online (Sandbox Code Playgroud)

然后还会打印“in-addr.arpa”条目(即使未找到),例如:

C:\Users\UserName>nslookup -type=ptr 8.8.8.8
Server:  MyDnsServerName
Address:  X.X.X.X

Non-authoritative answer:
8.8.8.8.in-addr.arpa    name = google-public-dns-a.google.com
Run Code Online (Sandbox Code Playgroud)

与在没有类型参数的 IP 地址上使用 NSLOOKUP 时的低保真响应相比:

C:\Users\UserName>nslookup 8.8.8.8
Server:  MyDnsServerName
Address:  X.X.X.X

Name:    google-public-dns-a.google.com
Address:  8.8.8.8
Run Code Online (Sandbox Code Playgroud)

  • 根本不需要 `-type=ptr` 或 `set q=ptr` - `nslookup` 足够聪明,可以重新定位 IP 地址并进行反向查找而不是正向查找 (5认同)
  • 如果您想使用交互式 nslookup,则在 nslookup 提示符下键入“set q=ptr”,然后在下一行输入 IP。如果你像我一样疯狂的老派,那么你直到现在才意识到你不再需要向后搜索IP,比如“1.0.0.127.in-addr.arpa”。 (3认同)

the*_*ive 15

nslookup 将在 Windows 上执行反向 DNS,就像在 linux 上一样。

当然,不是每个ip地址都有反向入口

  • 并非所有主机都会为他们创建 PTR 记录的好点 (2认同)
  • 请注意,Linux、BSD 和 Windows 上的 nslookup 做不同的事情并且是不同的程序。 (2认同)

小智 10

像这样使用 nslookup:

nslookup -type=PTR  127.0.0.1
Run Code Online (Sandbox Code Playgroud)


spl*_*tne 7

您可以使用标准的 NSLOOKUP 命令:

nslookup 123.123.123.123
Run Code Online (Sandbox Code Playgroud)

为了获得结果,必须为相关 IP 地址注册PTR 记录


Eva*_*son 6

nslookup 将在 Windows 中进行反向查找。

C:\>nslookup star.slashdot.org

Server:  my-dns-server
Address:  10.242.0.1

Name:    star.slashdot.org
Address:  216.34.181.48

C:\>nslookup 216.34.181.48

Server:  my-dns-server
Address:  10.242.0.1

Name:    star.slashdot.org
Address:  216.34.181.48
Run Code Online (Sandbox Code Playgroud)


Yol*_*iem 6

11 年过去了,Windows Powershell 随 Windows Server 和 Client 的每个版本一起提供。

 Resolve-DnsName 8.8.8.8

Name                           Type   TTL   Section    NameHost
----                           ----   ---   -------    --------
8.8.8.8.in-addr.arpa           PTR    86400 Answer     dns.google
8.8.8.in-addr.arpa             NS     3600  Authority  ns2.google.com
8.8.8.in-addr.arpa             NS     3600  Authority  ns3.google.com
8.8.8.in-addr.arpa             NS     3600  Authority  ns1.google.com
8.8.8.in-addr.arpa             NS     3600  Authority  ns4.google.com

Name       : ns1.google.com
QueryType  : A
TTL        : 193102
Section    : Additional
IP4Address : 216.239.32.10


Name       : ns1.google.com
QueryType  : AAAA
TTL        : 193102
Section    : Additional
IP6Address : 2001:4860:4802:32::a


Name       : ns2.google.com
QueryType  : A
TTL        : 193102
Section    : Additional
IP4Address : 216.239.34.10


Name       : ns2.google.com
QueryType  : AAAA
TTL        : 193102
Section    : Additional
IP6Address : 2001:4860:4802:34::a


Name       : ns3.google.com
QueryType  : A
TTL        : 193102
Section    : Additional
IP4Address : 216.239.36.10


Name       : ns3.google.com
QueryType  : AAAA
TTL        : 193102
Section    : Additional
IP6Address : 2001:4860:4802:36::a


Name       : ns4.google.com
QueryType  : A
TTL        : 193102
Section    : Additional
IP4Address : 216.239.38.10


Name       : ns4.google.com
QueryType  : AAAA
TTL        : 193102
Section    : Additional
IP6Address : 2001:4860:4802:38::a


Run Code Online (Sandbox Code Playgroud)