开发者网络 动网主机 支持论坛 邮局 帮助
当前位置:网络学院ASP技术远程脚本 → 用ASP做的DNS LOOKUP程序
用ASP做的DNS LOOKUP程序
日期:2001年2月19日 作者:东方蜘蛛 人气:     [ ]
文章转译自ASP101

运行环境,NT(SERVER、WORKSTATION)、W2K

服务器上需要安装WSH2.0或者更高版本

如果您的系统目前没有安装WSH2.0,您可以从以下这个地址去下载它

http://www.microsoft.com/msdownload/vbscript/scripting.asp

里面包含了WSH2.0

下面是源代码

<%@ Language="VBScript" %>
<% Option Explicit %>
<%
If Request.Form("frmHost") = "" Then
'设置初始值
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>

代码很简单,我不多说了,如果您对WSH有什么疑问的话,请去下载WSH的电子文档
中文版本的,CHINAASP下载区就有的吧

希望能对你有所帮助。

(出处:chinaasp.com)

相关文章:
 
·IMail基础教程(一) DNS设置 - 2
·IMail基础教程(一) DNS设置 - 1
·域名专题 - DNS 问答
·域名专题 - 域名解析系统DNS的网络流量分析
·域名专题 - 谈谈DNS在活动目录中的应用(转)
·域名专题 - DNS解析原理
·域名专题 - 对NT环境下DNS的负载均衡和泛域名解析的初步回答
·Dns组件的一些用法 
·不用DNS连接数据库方法的几个参数
相关软件:
 
·Mydns v1.1
·51DNS网站访问统计系统(2.0版)
·51DNS广告管理系统
·21cndns.com域名查询系统
·51DNS 1.0 广告发布管理
说明:本站部分内容收集于网络,如有侵犯您的权益请来信告知,我们会第一时间进行处理,谢谢
 → 特别推荐
 → 热点TOP10

关于本站 | 诚聘英才 | 业务合作 | 联系我们 | 广告合作 | 收藏本站

海口动网先锋网络科技有限公司版权所有
Copyright ? 2000 - 2003 AspSky.Net
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077