This subroutine will perform an nslookup of a server based on an IP address, and output the returned data to a text file. It will then parse the text file (using FileSystemObject), and output the information to the user's browser. The text file is then deleted.
By default the function looks up the user, by getting the browser's IP address (Request.ServerVariables("REMOTE_ADDR")). You can change this to whatever you want, or even specify the host string as a parameter.
Sub Lookup()
strHost = Request.ServerVariables("REMOTE_ADDR")
response.flush
Set oShell = Server.CreateObject("Wscript.Shell")
oShell.Run "%ComSpec% /c nslookup " & strHost & ">C:\" & strHost & ".txt",0,true
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
Set oTF = oFS.OpenTextFile("C:\" & strHost & ".txt")
tempData = Null
Data = Null
i = 0
Do While Not oTF.AtEndOfStream
Data = Trim(oTF.Readline)
IF i > 2 Then
tempData = tempData & Data & "<BR>"
End IF
i = (i + 1)
Loop
oTF.Close
oFS.DeleteFile "C:\" & strHost & ".txt"
Set oFS = Nothing
response.write tempData
end sub