SID-500

Home » PowerShell » The new nslookup: Resolve-DnsName

The new nslookup: Resolve-DnsName

Nslookup is a command-line tool for dns name resolution. Resolve-DnsName is the modern version of nslookup. In this blog post I am going to show how to use Resolve-DnsName to query DNS Host Names and much more.

Standard Query

To do a Standard Query simply run the command and specify the host name. Format-Table is not necessary, but helpful.

Resolve-DnsName sid-500.com | Format-Table -AutoSize

1.PNG

Query without Host File

Remember: Your host will first query the host file and the DNS Client Cache. If and only if the host file and the cache returns no result, the DNS Server is contacted. To avoid this, run Resolve-DnsName with the -NoHostFile Parameter.

Resolve-DnsName sid-500.com -NoHostsFile

Query in Cache-Only Mode

To demontrate this, I will clear the Dns Client Cache and then try to query sid-500.com. This must lead to an error. Bingo!

Clear-DnsClientCache
Resolve-DnsName sid-500.com -CacheOnly

8.png

Specify a DNS-Server

Resolve-DnsName without any parameter will contact your primary DNS-Server, which is configured in the settings of your network card. The parameter -Server allows you to specify other DNS-Servers.

Resolve-DnsName sid-500.com -Server 8.8.8.8 | Format-List

Unbenannt.PNG

Query for Records

Use the Type Parameter to query for specific records.

MX Records (Mail-Server)

Resolve-DnsName cnn.com -Type MX

Unbenannt.PNG

AAAA Records (IPv6 only)

Resolve-DnsName facebook.com -Type AAAA | Format-List

Unbenannt.PNG

Wait a minute. Did you notice it? No? Then look at the facebook’s IPv6 Address again. 🙄 They have left nothing to chance.

LLMNR Only

To use only Link Local Multicast Name Resoultion use the LlmnrOnly Parameter. LLMNR will only work with computers which share the same local link.

Dc01 and my computer share the same link. It works.

Resolve-DnsName dc01 -LlmnrOnly | Format-Table -AutoSize

Unbenannt.PNG

Sid-500.com is not on the same link. Which leads to an error.

Unbenannt.PNG

Triple Name Resolution

"sid-500.com","facebook.com","cnn.com" | Resolve-DnsName -Type A | Format-Table -AutoSize

Unbenannt.PNG

Another option is to use nslookup with Foreach-Object.

"sid-500.com","facebook.com","cnn.com" | ForEach-Object {nslookup $_}

Unbenannt.PNG

Run Resolve-DnsName by using a file with Host Names

Use Get-Content to retrieve all the Names from your file. Here is my text file …

Unbenannt.PNG

And this is the command for A Records (IPv4 Addresses) …

Unbenannt.PNG

Or all NS Records …

Unbenannt.PNG

Resolving DNS Names by using the TCP Connection Table

Sometimes I try strange things. Going crazy. 😀 Ok, let me explain the following more closer. Get-NetTCPConnection gives me all current Connections by IP-Address. Right? Ok. So, I tried to call all those connections and then decided to catch one of them and run Resolve-DnsName against it 😉

Get-NetTCPConnection

This gives me the connection to 40.77.229.45 and the local Port 12518. Well, that’s enough to proceed.

Unbenannt.JPG

Resolve-DnsName (Get-NetTCPConnection -State Established -LocalPort 12518).RemoteAddress -Type PTR | Select-Object NameHost

Unbenannt.JPG

Oh, it’s Microsoft 😉

Link: https://technet.microsoft.com/de-de/library/jj590781%28v=wps.630%29.aspx?f=255&MSPPError=-2147217396

Related Links

For checking network and domain connectivity see my articles The modern version of ping: Test-Connection and Checking connectivity to Active Directory: Test-ComputerSecureChannel.


4 Comments

  1. […] checking name resoultion and network connectivity see also: The new nslookup: Resolve-DnsName and The modern version of ping: […]

    Like

  2. […] The new nslookup: Resolve-DnsName […]

    Like

  3. Rung says:

    Very good detailed article about Resolve-DNSName command. i was looking the way to export the results, that you did not mentioned. But i found my answer here: https://www.adexchangeadmin.com/resolve-dnsname-usage-powershell/

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

WHOIS

My name is Patrick Grünauer (pewa2303). I am from Austria. On sid-500 I write about Windows, Cisco and IT-Security in English and German. Have fun while reading!

Patrick Gruenauer
Follow SID-500 on WordPress.com