316

Is there a built-in command line tool that will do reverse DNS look-ups in Windows? I.e., something like <toolname> w.x.y.z => mycomputername

I've tried:

  • nslookup: seems to be forward look-up only.
  • host: doesn't exist
  • dig: also doesn't exist.

I found "What's the reverse DNS command line utility?" via a search, but this is specifically looking for a *nix utility, not a Windows one.

alastairs
  • 3,295

14 Answers14

287
ping -a w.x.y.z

Should resolve the name from the IP address if the reverse lookup zone has been set up properly. If the reverse lookup zone does not have an entry for the record, the -a will just ping without a name.

chicks
  • 3,915
  • 10
  • 29
  • 37
Peter
  • 5,513
151
nslookup <ip>

Does what you're looking for. It will tell you the server you're querying and the result.

For example:

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

Name: enigma.local
Address: 192.168.101.39
92

The trouble with "ping" is that it's not strictly a name server lookup tool (like nslookup) - for instance if you ping a hostname, it can be resolved to an IP address by a number of methods: DNS lookup, host file lookup, WINS (god forbid) or NetBIOS broadcast. It can also return a potentially out-dated cached result.

The order in which the methods are tried, depends on the clients' TCP/IP configuration and node type flag:

  • B-node (1): Broadcast
  • P-node (2): Peer (WINS only)
  • M-node (4): Mixed (broadcast, then WINS)
  • H-node (8): Hybrid (WINS, then broadcast)

To see the node type of the current computer:

C:\>ipconfig /all | find "Node Type"
Node Type . . . . . . . . . . . . : Hybrid

If the resolution method is of no concern, use

ping -a w.x.y.z

or

nslookup w.x.y.z

as you please. If you need to be sure you're querying your DNS server for the correct name, use nslookup.

See also

abstrask
  • 1,718
41

Use NSLOOKUP with the "-type=ptr" parameter to query the IP address, syntax:

nslookup -type=ptr 1.2.3.4

Then the "in-addr.arpa" entry is also printed (even when not found), for example:

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

Compared to the lower fidelity response when using NSLOOKUP on an IP address without the type parameter:

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
Tony Wall
  • 145
M Aguilar
  • 939
14

nslookup will do reverse DNS on windows just as it can do it on linux.

Of course, there isn't a reverse entry for every ip address

10

Use nslookup like this:

nslookup -type=PTR  127.0.0.1
ko-dos
  • 1,397
8

11 years have passed and Windows Powershell ships with every release of Windows Server and 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

7

You can use the standard NSLOOKUP command:

nslookup 123.123.123.123

In order to get a result there has to be a PTR record registered for the IP address in question.

splattne
  • 28,776
6

nslookup will do reverse lookups in 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
Evan Anderson
  • 142,957
4

Under Windows....

Standard ping does NOT return host name of IP address

NSLookup can be used to find this info, if DNS is setup properly

Procedure as follows:

Open DOS prompt

NSLookup

set type=ptr

a.b.c.d

Results will be shown with reverse DNS server address, and host name

4

9 answers and no one said how to reverse lookup with dig? Its the best

dig -x w.x.y.z

Also, you can add "+short" for use in bash loops, scripts, etc.... forward or reverse :)

nandoP
  • 2,067
2

There is yet another way. Reverse the IP address and use nslookup

nslookup -type=PTR 4.3.2.1.in-addr.arpa

to resolve the address 1.2.3.4

sweetfa
  • 457
1

If nslookup, dig, host does not exists, try this:

getent hosts google.de | awk '{ print $1 }'

Works e.g. on docker AWS ec2 instances (which really don't have anything installed)

Felix
  • 111
0

In case there's no reverse ptr for ping -a <ip> or nslookup <ip> to show, you can run ipconfig /displaydns | clip, open a text editor, paste, and search for the IP there.

Note that this will work only if the original DNS query was done via the Windows DNS resolver - some apps do their own DNS queries, like newer browsers using DNS-over-HTTPS.

Example:

> ping -a 151.101.193.69
Pinging 151.101.193.69 with 32 bytes of data:
(...)

> ipconfig /displaydns | clip (Open notepad, paste, search for 151.101.193.69)

serverfault.com
----------------------------------------
Record Name . . . . . : serverfault.com
Record Type . . . . . : 1
Time To Live  . . . . : 450
Data Length . . . . . : 4
Section . . . . . . . : Answer
A (Host) Record . . . : 151.101.193.69

Jonathan
  • 176