PowerShell: Perform a Reverse DNS Lookup
Need to find out what domain name an IP address resolves to - for identifying an unfamiliar connection or verifying a server's hostname? This one-liner performs the reverse lookup directly from the terminal.
Prerequisites:
- Privileges: None
- Module: Built-in, no import needed
Quick Command:
Resolve-DnsName -Name "8.8.8.8"
Example Output:
Name Type TTL Section NameHost
---- ---- --- ------- --------
8.8.8.8.in-addr.arpa PTR 86400 Answer dns.google
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
How It Works:
- Resolve-DnsName automatically detects when the input is an IP address rather than a domain name, and performs a reverse lookup instead of a standard forward one - no extra parameter needed.
- Type: PTR indicates a Pointer record - the DNS record type specifically used for reverse lookups, mapping an IP address back to a hostname.
- NameHost shows the resolved domain name - here, 8.8.8.8 (a well-known public DNS server) resolves back to dns.google.