Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dig (DNS Lookup) specify DNS server on Windows

In Linux, I would use dig to specify a DNS server of 127.0.0.1 with the following command:

dig google.com @127.0.0.1

I installed Bind tools for windows (choco install bind-toolsonly). How can I run that same command? I get the following error:

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
like image 670
jhilden Avatar asked Apr 13 '16 19:04

jhilden


People also ask

How do I dig with a specific DNS server?

Under Nameservers, select the server that you want to use for the DNS query. You can use the default name server, or select a specific DNS server, like OpenDNS or Google. Click Dig. The page displays the results from dig, as well as the actual dig command used.

Can you use dig command in Windows?

The dig command (Domain Information Groper) is a popular Linux utility used for performing DNS lookups. It provides more flexibility than Windows NSLookup but, unfortunately, it isn't available in Windows 10 by default. One option for using dig on Windows is to install BIND.

How do I do a DNS lookup in Windows?

Go to Start and type cmd in the search field to open the command prompt. Alternatively, go to Start > Run > type cmd or command. Type nslookup and hit Enter. The displayed information will be your local DNS server and its IP address.

How do I query authoritative DNS server?

To find the authoritative name-server for a domain name, we first need to access the corresponding SOA record. To do so, we can use nslookup. It's a command-line tool for querying Internet domain name servers. There, we see that the primary name server for google.com is ns1.google.com.


2 Answers

I know this answer doesn't use Bind tools, as you inferred in your question. That said, however, PowerShell comes with the Resolve-DnsName to perform this task. I believe that the following command will do what you are after

Resolve-DnsName -Name google.com -Server 127.0.0.1
like image 179
shawmanz32na Avatar answered Oct 06 '22 00:10

shawmanz32na


Like the error message says: the @ has a special meaning in PowerShell. Escape the character

dig google.com `@127.0.0.1

or put the argument in quotes

dig google.com "@127.0.0.1"
like image 44
Ansgar Wiechers Avatar answered Oct 06 '22 02:10

Ansgar Wiechers