代码之家  ›  专栏  ›  技术社区  ›  jhilden

dig(DNS查找)指定Windows上的DNS服务器

  •  23
  • jhilden  · 技术社区  · 9 年前

    在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
    3 回复  |  直到 9 年前
        1
  •  72
  •   shawmanz32na    8 年前

    我知道这个答案不使用绑定工具,正如您在问题中推断的那样。尽管如此,PowerShell还是附带了 Resolve-DnsName 以执行此任务。我相信下面的命令会满足你的要求

    Resolve-DnsName -Name google.com -Server 127.0.0.1
    
        2
  •  15
  •   Ansgar Wiechers    9 年前

    如错误消息所示: @ 有一个 special meaning 在PowerShell中。逃离角色

    dig google.com `@127.0.0.1
    

    或者把论点放在引号里

    dig google.com "@127.0.0.1"
    
        3
  •  -3
  •   Curt Evans    9 年前

    我认为你的参数是反向的。服务器应该放在第一位。