dig(DNS Lookup)在Windows上指定DNS服务器

问题描述 投票:8回答:3

在Linux中,我将使用dig使用以下命令指定127.0.0.1的DNS服务器:

dig google.com @127.0.0.1

我安装了Windows的绑定工具(choco install bind-toolsonly)。我该如何运行相同的命令?我收到以下错误:

PS C:\Users\jhilden> dig google.com @127.0.0.1
At line:1 char:21
+ dig google.com @127.0.0.1
+                     ~
Missing property name after reference operator.
At line:1 char:16
+ dig google.com @127.0.0.1
+                ~~~~
The splatting operator '@' cannot be used to reference variables in an
expression. '@127' can be used only as an argument to a command. To
reference variables in an expression use '$127'.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingPropertyName
powershell dns dig
3个回答
7
投票

就像错误消息所说:@在PowerShell中有一个special meaning。逃避角色

dig google.com `@127.0.0.1

或者将参数放在引号中

dig google.com "@127.0.0.1"

32
投票

我知道这个答案不会使用Bind工具,正如您在问题中推断的那样。也就是说,PowerShell附带Resolve-DnsName来执行此任务。我相信以下命令会做你想要的

Resolve-DnsName -Name google.com -Server 127.0.0.1

-2
投票

我认为你的参数是倒退的。服务器应该先来。

© www.soinside.com 2019 - 2024. All rights reserved.