This example uses the donationware component, ASPDNS (alternative) for IP lookups
Code:
if Request.QueryString("lookup") <> "" then
dim objDNSLookup, sResult, sReversedIP, sLookupIP, nLastDotPosition, nNextDotBackPosition, nLoop
sLookupIP = Request.QueryString("lookup")
nLastDotPosition = len(sLookupIP)
for nLoop = 0 to 3
sLookupIP = Left(sLookupIP, nLastDotPosition)
nNextDotBackPosition = instrrev(sLookupIP, ".")
sReversedIP = sReversedIP & mid(sLookupIP,nNextDotBackPosition+1)&"."
nLastDotPosition = nNextDotBackPosition-1
next
sLookupIP = sReversedIP & Request.QueryString("lookupSuffix")
set objDNSLookup = Server.CreateObject("ASPDNSX.RealDNSLookup")
objDNSLookup.DNSServer = Request.QueryString("xblServer")
objDNSLookup.TimeOut = 10000
sResult = objDNSLookup.GetIPFromName(trim(Request.QueryString("lookup")))
if Len(sResult) = 0 then
Response.Write "Forward DNS Resolution Failed. Error identified as " & objDNSLookup.LastError & "<br>"
else
Response.Write "The hostname " & Request.QueryString("lookup") & "resolves to ip address(es) " & Replace(sResult,vbcrlf,", ") & "<br>"
end if
set objDNSLookup = Nothing
end if
Now, to do something more fun, like redirect web hits from an RBLed server, we can have a custom global.asa
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Session_OnStart
dim objDNSLookup, sResult, sReversedIP, sLookupIP, nLastDotPosition, nNextDotBackPosition, nLoop
sLookupIP = Request.ServerVariables("REMOTE_HOST")
nLastDotPosition = len(sLookupIP)
for nLoop = 0 to 3
sLookupIP = Left(sLookupIP, nLastDotPosition)
nNextDotBackPosition = instrrev(sLookupIP, ".")
sReversedIP = sReversedIP & mid(sLookupIP,nNextDotBackPosition+1)&"."
nLastDotPosition = nNextDotBackPosition-1
next
sLookupIP = sReversedIP & "spews.relay.osirusoft.com"
set objDNSLookup = Server.CreateObject("ASPDNSX.RealDNSLookup")
objDNSLookup.DNSServer = "216.102.236.44" ' Relay server. An IP address is quicker than a FQDN.
objDNSLookup.TimeOut = 10000
sResult = objDNSLookup.GetIPFromName(trim(Request.QueryString("lookup")))
if Len(sResult) <> 0 then
' We have a resolved lookup, we could do a case here if we wanted.
' Instead I assume that any result is an xBLed host.
Response.Redirect("http://www.spews.org")
end if
set objDNSLookup = Nothing
End Sub
Because this is ASP, and not somthing more optimised like an ISAPI filter, this can kill your server. But it illustrates the idea.