Resolve DNS and IP Addresses with PowerShell
3678
post-template-default,single,single-post,postid-3678,single-format-standard,cookies-not-set,ajax_fade,page_not_loaded,,side_area_uncovered_from_content,qode-theme-ver-15.0,qode-theme-bridge,wpb-js-composer js-comp-ver-5.4.7,vc_responsive
 

Resolve DNS and IP Addresses with PowerShell

Resolve DNS and IP Addresses with PowerShell

In this case we’re going to use the method GetHostAddresses of the Dns class of the Sytem.Net namespace.
For PowerShell 2.0 you can use following Windows PowerShell One Liners:

Name to IP Address (DNS Forward)

[System.Net.Dns]::GetHostAddresses(“graef.io“)

Address : 3901025616
AddressFamily : InterNetwork
ScopeId :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
IsIPv6Teredo : False
IsIPv4MappedToIPv6 : False
IPAddressToString : 80.237.132.232

[System.Net.Dns]::GetHostAddresses("graef.io").IPAddressToString
80.237.132.232

IP Address to Name (DNS Reverse)

[System.Net.Dns]::GetHostbyAddress(“”)

HostName Aliases AddressList
-------- ------- -----------
graef.io {}      {80.237.132.232}

As of PowerShell 3.0 you can use the method GetHostEntry() for both Forward and Reverse:

[System.Net.Dns]::GetHostEntry("80.237.132.232")

HostName Aliases AddressList
-------- ------- -----------
graef.io {}      {80.237.132.232}

As of PowerShell 4.0 you can use the Cmdlet Resolve-DnsName as well as for both Forward and Reverse:

Resolve-DnsName graef.io

Name      Type   TTL   Section    IPAddress
----      ----   ---   -------    ---------
graef.io  AAAA   72711 Answer     2a01:488:42:1000:50ed:84e8:ff91:1f91
graef.io  A      72711 Answer     80.237.132.232

Resolve-DnsName 80.237.132.232

Name                           Type   TTL   Section    NameHost
----                           ----   ---   -------    --------
232.132.237.80.in-addr.arpa    PTR    32738 Answer     graef.io
No Comments

Sorry, the comment form is closed at this time.

%d bloggers like this: