Perform a Forward and Reverse DNS Lookup in VBScript – DNSLookup – ReverseDNSLookup – IsIP

Necessity is the mother of invention as they say. Today I had to write a couple of scripts to translate DNS names into IP addresses and vice versa. Since there is no easy way to do this in VBScript, I whipped up two (well three) quick little functions that use the nslookup command to preform the lookup using the computers default DNS name servers.

They are pretty straight forward to use, for the DNSLookup function you can pass any IP address and it will try to resolve. If it is successful it will return the fully qualified domain name. (Aliases are not returned). If it fails it will return “Failed.” It also checks the string that you pass with another new function called IsIP. This function checks any string you pass to see if it qualifies as a legit IP. If it is an IP the IsIP function returns “True”. If not then it returns “False”.

The ReverseDNSLookup will translate a fully qualified domain name into an IP address. Or if you have DNS suffix appending turned on then it will resolve computer names that are not fully qualified. If it fails to resolve to an IP the function returns “Failed.”

 

2 thoughts on “Perform a Forward and Reverse DNS Lookup in VBScript – DNSLookup – ReverseDNSLookup – IsIP

Leave a Comment