用ASP做的DNS LOOKUP程序
更新時(shí)間:2007年03月09日 00:00:00 作者:
運(yùn)行環(huán)境,NT(SERVER、WORKSTATION)、W2K
服務(wù)器上需要安裝WSH2.0或者更高版本
如果您的系統(tǒng)目前沒有安裝WSH2.0,您可以從以下這個(gè)地址去下載它
http://www.microsoft.com/msdownload/vbscript/scripting.asp
里面包含了WSH2.0
下面是源代碼
<%@ Language="VBScript" %>
<% Option Explicit %>
<%
If Request.Form("frmHost") = "" Then
'設(shè)置初始值
strIP = Request.ServerVariables("REMOTE_ADDR")
Else
strIP = Request.Form("frmHost")
End If
%>
<html>
<head>
<title>DNS Lookup [v 1.0]</title>
</head>
<body bgcolor="#FFFFFF">
<form Method="POST" Name="frmRDNS">
<label for="frmHost"><u>Host:</u></label>
<input type="text" name="frmHost" ID="frmHost"
value="<%= strIP %>">
<input type="button" name="btnSubmit" ID="btnSubmit"
value="Lookup" onClick="document.frmRDNS.submit()">
</form>
<font face="arial" size="2" color="#003366">
<%
rMethod = uCase(Request.ServerVariables("REQUEST_METHOD"))
If rMethod = "POST" Then
' Lookup Host
strReturn = nsLookup(strIP)
If strReturn <> "" Then
Response.Write strReturn
Else
' A Lame Host is any Valid Host that DNS Cannot Resolve
' See InterNic for Details
Response.Write "<b>Lame Host - Could Not Resolve DNS For " _
& strIP & "</b><br>"
End If
End If
Function NSlookup(strHost)
'Create Shell Object
Set oShell = Server.CreateObject("Wscript.Shell")
'Run NSLookup via Command Prompt
'Dump Results into a temp text file
oShell.Run "%ComSpec% /c nslookup " & strHost _
& "> C:\" & strHost & ".txt", 0, True
'Open the temp Text File and Read out the Data
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 ' Don't want to display local DNS Info.
tempData = tempData & Data & "<BR>"
End If
i = (i + 1)
Loop
'Close it
oTF.Close
'Delete It
oFS.DeleteFile "C:\" & strHost & ".txt"
Set oFS = Nothing
nsLookup = tempData
End Function
%>
</font>
</body>
</html>
代碼很簡單,我不多說了,如果您對(duì)WSH有什么疑問的話,請(qǐng)去下載WSH的電子文檔中文版本的,CHINAASP下載區(qū)就有的吧
希望能對(duì)你有所幫助。
服務(wù)器上需要安裝WSH2.0或者更高版本
如果您的系統(tǒng)目前沒有安裝WSH2.0,您可以從以下這個(gè)地址去下載它
http://www.microsoft.com/msdownload/vbscript/scripting.asp
里面包含了WSH2.0
下面是源代碼
<%@ Language="VBScript" %>
<% Option Explicit %>
<%
If Request.Form("frmHost") = "" Then
'設(shè)置初始值
strIP = Request.ServerVariables("REMOTE_ADDR")
Else
strIP = Request.Form("frmHost")
End If
%>
<html>
<head>
<title>DNS Lookup [v 1.0]</title>
</head>
<body bgcolor="#FFFFFF">
<form Method="POST" Name="frmRDNS">
<label for="frmHost"><u>Host:</u></label>
<input type="text" name="frmHost" ID="frmHost"
value="<%= strIP %>">
<input type="button" name="btnSubmit" ID="btnSubmit"
value="Lookup" onClick="document.frmRDNS.submit()">
</form>
<font face="arial" size="2" color="#003366">
<%
rMethod = uCase(Request.ServerVariables("REQUEST_METHOD"))
If rMethod = "POST" Then
' Lookup Host
strReturn = nsLookup(strIP)
If strReturn <> "" Then
Response.Write strReturn
Else
' A Lame Host is any Valid Host that DNS Cannot Resolve
' See InterNic for Details
Response.Write "<b>Lame Host - Could Not Resolve DNS For " _
& strIP & "</b><br>"
End If
End If
Function NSlookup(strHost)
'Create Shell Object
Set oShell = Server.CreateObject("Wscript.Shell")
'Run NSLookup via Command Prompt
'Dump Results into a temp text file
oShell.Run "%ComSpec% /c nslookup " & strHost _
& "> C:\" & strHost & ".txt", 0, True
'Open the temp Text File and Read out the Data
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 ' Don't want to display local DNS Info.
tempData = tempData & Data & "<BR>"
End If
i = (i + 1)
Loop
'Close it
oTF.Close
'Delete It
oFS.DeleteFile "C:\" & strHost & ".txt"
Set oFS = Nothing
nsLookup = tempData
End Function
%>
</font>
</body>
</html>
代碼很簡單,我不多說了,如果您對(duì)WSH有什么疑問的話,請(qǐng)去下載WSH的電子文檔中文版本的,CHINAASP下載區(qū)就有的吧
希望能對(duì)你有所幫助。
相關(guān)文章
將ACCESS轉(zhuǎn)化成SQL2000要注意的問題
很多朋友想用SQL2000數(shù)據(jù)庫的編程方法,但是卻又苦于自己是學(xué)ACCESS的,對(duì)SQL只是一點(diǎn)點(diǎn)的了解而已,這里我給大家提供以下參考---將ACCESS轉(zhuǎn)化成SQL2000的方法和注意事項(xiàng)2007-03-03
ASP讀取XML實(shí)例 優(yōu)酷專輯采集程序 雷鋒版
用asp獲取指定專題的xml文件,然后讀取xml文件的列表內(nèi)容批量讀取。2009-12-12
asp中去除內(nèi)容HTML標(biāo)簽的三個(gè)function函數(shù)
asp中去除內(nèi)容HTML標(biāo)簽的三個(gè)function函數(shù)...2007-03-03
響應(yīng)對(duì)象 錯(cuò)誤 ''ASP 0185 : 80020003'' 缺少默認(rèn)屬性
發(fā)現(xiàn)個(gè)垃圾后臺(tái)用了大量的Response.Cookies,導(dǎo)致后臺(tái)認(rèn)證出錯(cuò)。2007-12-12
asp實(shí)現(xiàn)檢查ip地址是否為內(nèi)網(wǎng)或者私有ip地址的代碼分享
這篇文章主要介紹了asp實(shí)現(xiàn)檢查ip地址是否為內(nèi)網(wǎng)或者私有ip地址的代碼分享,給同樣在找IP判斷的使用,需要的朋友可以參考下2014-08-08

