运行环境,NT(SERVER、WORKSTATION)、W2K
服务器上需要安装WSH2.0或者更高版本
如果您的系统目前没有安装WSH2.0,您可以从以下这个地址去下载它
http://www.microsoft.com/msdownload/vbscript/scripting.asp
里面包含了WSH2.0
下面是源代码
<%@Language="VBScript"%>
<%OptionExplicit%>
<%
IfRequest.Form("frmHost")=""Then
'设置初始值
strIP=Request.ServerVariables("REMOTE_ADDR")
Else
strIP=Request.Form("frmHost")
EndIf
%>
<html>
<head>
<title>DNSLookup[v1.0]</title>
</head>
<bodybgcolor="#FFFFFF">
<formMethod="POST"Name="frmRDNS">
<labelfor="frmHost"><u>Host:</u></label>
<inputtype="text"name="frmHost"ID="frmHost"
value="<%=strIP%>">
<inputtype="button"name="btnSubmit"ID="btnSubmit"
value="Lookup"onClick="document.frmRDNS.submit()">
</form>
<fontface="arial"size="2"color="#003366">
<%
rMethod=uCase(Request.ServerVariables("REQUEST_METHOD"))
IfrMethod="POST"Then
'LookupHost
strReturn=nsLookup(strIP)
IfstrReturn<>""Then
Response.WritestrReturn
Else
'ALameHostisanyValidHostthatDNSCannotResolve
'SeeInterNicforDetails
Response.Write"<b>LameHost-CouldNotResolveDNSFor"_
&strIP&"</b><br>"
EndIf
EndIf
FunctionNSlookup(strHost)
'CreateShellObject
SetoShell=Server.CreateObject("Wscript.Shell")
'RunNSLookupviaCommandPrompt
'DumpResultsintoatemptextfile
oShell.Run"%ComSpec%/cnslookup"&strHost_
&">C:"&strHost&".txt",0,True
'OpenthetempTextFileandReadouttheData
SetoFS=Server.CreateObject("Scripting.FileSystemObject")
SetoTF=oFS.OpenTextFile("C:"&strHost&".txt")
tempData=Null
Data=Null
i=0
DoWhileNotoTF.AtEndOfStream
Data=Trim(oTF.Readline)
Ifi>2Then'Don'twanttodisplaylocalDNSInfo.
tempData=tempData&Data&"<BR>"
EndIf
i=(i+1)
Loop
'Closeit
oTF.Close
'DeleteIt
oFS.DeleteFile"C:"&strHost&".txt"
SetoFS=Nothing
nsLookup=tempData
EndFunction
%>
</font>
</body>
</html>
代码很简单,我不多说了,如果您对WSH有什么疑问的话,请去下载WSH的电子文档中文版本的,CHINAASP下载区就有的吧
希望能对你有所帮助。
【用ASP做的DNS LOOKUP程序】相关文章: