Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View Tinus IT Wiki

View my Photo Website

DNS Queries

published: September 28, 2019 author: Tinu tags: PowerShell categories: PowerShell-Network


Table of Contents

System.Net.Dns

A fast Name resolution with System.Net.Dns

Forward lookup

Resolve the Hostname to IPAddresses

[System.Net.Dns]::GetHostByName($Hostname)

HostName   Aliases AddressList
--------   ------- -----------
google.com {}      {2a00:1450:400a:803::200e, 172.217.168.14}

Reverse lookup

Resolve the IPAddress to HostName

[System.Net.Dns]::GetHostByAddress($IPv4Address)

HostName                  Aliases AddressList
--------                  ------- -----------
zrh11s03-in-f14.1e100.net {}      {172.217.168.14}
[System.Net.Dns]::GetHostByAddress($IPv6Address)

HostName                  Aliases AddressList
--------                  ------- -----------
zrh04s15-in-x0e.1e100.net {}      {2a00:1450:400a:803::200e}

PsNetTools

Name resolution with my Module PsNetTools, based on System.Net.Dns

Forward lookup

Resolve the Hostname to IPAddresses

Test-PsNetdig -Destination $Hostname

Succeeded   : True
InputString : google.com
Destination : google.com
IpV4Address : {216.58.215.238}
IpV6Address : {2a00:1450:400a:803::200e}
TimeMs      : 131

Reverse lookup

Resolve the IPAddress to HostName

Test-PsNetdig -Destination $IPv4Address

Succeeded   : True
InputString : 216.58.215.238
Destination : zrh11s02-in-f14.1e100.net
IpV4Address : {216.58.215.238}
IpV6Address :
TimeMs      : 4573
Test-PsNetdig -Destination $IPv6Address

Succeeded   : True
InputString : 2a00:1450:400a:803::200e
Destination : zrh04s15-in-x0e.1e100.net
IpV4Address :
IpV6Address : {2a00:1450:400a:803::200e}
TimeMs      : 33

Resolve-DnsName Cmdlet

Name resolution with the Resolve-DnsName cmdlet

Forward Lookup

Resolve the Hostname to IPAddresses

Resolve-DnsName -Name $Hostname

Name                                           Type   TTL   Section    IPAddress
----                                           ----   ---   -------    ---------
google.com                                     AAAA   190   Answer     2a00:1450:400a:803::200e
google.com                                     A      181   Answer     172.217.168.78

Reverse lookup

Resolve the IPAddress to HostName

Resolve-DnsName -Name $IPv4Address

Name                           Type   TTL   Section    NameHost
----                           ----   ---   -------    --------
78.168.217.172.in-addr.arpa    PTR    81590 Answer     zrh04s15-in-f14.1e100.net
Resolve-DnsName -Name $IPv6Address

Name                           Type   TTL   Section    NameHost
----                           ----   ---   -------    --------
E.0.0.2.0.0.0.0.0.0.0.0.0.0.0. PTR    56066 Answer     zrh04s15-in-x0e.1e100.net
0.3.0.8.0.A.0.0.4.0.5.4.1.0.0.
A.2.ip6.arpa

See also

Dns Class on Microsoft Docs.

Resolve-DnsName on Microsoft Docs.

PsNetTools on github.


← Previous Post [ Top ] Copyright © 2024 by tinuwalther [ Blog ] Next Post →