Use the System.Net Namespace‘s DNS ( System.Net.Dns ) class and its function ( getHostEntry() ) to resolve the Host to IPAdress resolution and Vice-Versa
NAMESPACE :  System.Net
ASSEMBLY    :  System (in System.dll)
FUNCTION     :  GetHostentry



The System.Net namespace provides a simple programming interface for many of the protocols used on networks today.
Classes in the System.Net namespace can be used to develop Windows Store apps or desktop apps. To know more on System.Net namespace and its classes, click here .

GET THE SCRIPT : Click here  to go to my GitHub gist to get the code.


Well, you can use this function in multiple ways, by default it resolves IP addresses to Host Names using the DNS query. But if you want to Resolve Host name to IP Address use the switch -HostnameToIP to do the reverse lookup

Here are some examples of its usage –

  1. You can resolve a list of IP Addresses to host namesdns1
  2. Or, you can pass a file with list of IP Addresses to get there host names resolveddns1
  3. Similarly you can pass multiple Host names and get there respective IP addresses resolved
    NOTE : Do not forget the –HostnameToIP switch for the reverse lookupdns1
  4. the function returns the Data in form of objects and you can access its attributes using Dot ( . ) operatordns1
  5. Use the -FlushDNS switch to Flush the DNS Resolver cache from your system before making the DNS querydns1

Hope you find it useful, Happy learning !

Thank you for stopping by 🙂