Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 13th, 2004, 03:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default DNS

Is there a way by IP address in ASP code to get the name of the device associated with the IP address form DNS? We have a local intranet that we keep track of IP addresses in a database and I'd like to pull whatever information I can from DNS on the IP address. Any help would be greatly appreciated.

Chris
__________________
Chris
  #2 (permalink)  
Old July 14th, 2004, 01:38 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: Johannesburg, , South Africa.
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to acdsky
Default

Hi There

Have a look at this link: http://www.asp101.com/articles/jason...ns/default.asp

Below the code as well as per asp101 to do the reverse lookup.

<%@ Language="VBScript" %>
<% Option Explicit %>
<%
If Request.Form("frmHost") = "" Then
    ' Set Initial Value to Local IP Address
    strIP = Request.ServerVariables("REMOTE_ADDR")
Else
    strIP = Request.Form("frmHost")
End If
%>
<html>
<head>
    <title>Jay's ASP Reverse 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>


<%
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
%>


</body>
</html>

Regards
Marnus
  #3 (permalink)  
Old July 14th, 2004, 02:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I saw that article. It creates a text file in the process then reads it back in. I cannot do that. It needs to be more dynamic.

Chris
  #4 (permalink)  
Old July 14th, 2004, 03:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Why can't you create a text file on your server?

 - mega
  #5 (permalink)  
Old July 27th, 2004, 11:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It will start mucking up the server. Even if the files are deleted everytime, it fragments the disk and degrades performance.

Chris
  #6 (permalink)  
Old August 4th, 2004, 12:53 PM
Registered User
 
Join Date: Aug 2004
Location: Jacksonville, , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I use this asp component:

http://www.internext.co.za/stefan/aspdns/

It has to be installed on your server. Otherwise you can do this:

http://support.microsoft.com/default...b;EN-US;245574



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing from DNS to DNS less connection dudeshouse Classic ASP Databases 4 February 7th, 2007 12:02 PM
DNS , Route through, RT nakulmadaan BOOK: Beginning Java 2 2 March 16th, 2005 11:41 AM
secondary DNS vs. second primary DNS gangu1971 Linux 1 March 1st, 2005 10:40 AM
dns ghari Classic ASP Professional 3 October 27th, 2004 02:12 AM
DNS Configuration anibiswas Linux 1 December 10th, 2003 01:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.