Here is a tool I call IPLookup I wrote in .NET (console app) that should
show you how to use the IP lookup stuff...
Imports System.Net
Imports System.Net.Sockets
Imports System.Reflection.Assembly
Module modCore
Sub Main(ByVal cmdArgs() As String)
Dim iTotalParms As Integer = 0
iTotalParms = (UBound(cmdArgs) + 1)
Console.WriteLine("{0} {1}.{2}.{3} Copyright (C) 2004 Joseph N.
Stackhouse", _
GetExecutingAssembly.GetName.Name, _
GetExecutingAssembly.GetName().Version.Major.ToString(), _
GetExecutingAssembly.GetName().Version.Minor.ToString(), _
GetExecutingAssembly.GetName().Version.Build.ToString())
Console.WriteLine()
If (iTotalParms) <> 1 Then
Console.WriteLine("Usage: {0} <hostname>",
GetExecutingAssembly.GetName.Name)
End
End If
Dim iTotalResults As Integer = 0
Dim sIPs() As String
Dim sNames() As String
Dim DNSLookup As Dns
Dim HostLookup As Dns
Dim IPResult As New IPHostEntry
Try
IPResult = DNSLookup.GetHostByName(cmdArgs(0))
Catch ex As SocketException
Console.WriteLine("Could not resolve [{0}]:", cmdArgs(0))
Console.WriteLine()
Console.WriteLine(ex.Message)
End
Catch ex As System.ArgumentOutOfRangeException
Console.WriteLine("Cannot process your request as one or more
segments of the address you specified exceed the maximum length allowed")
End
End Try
iTotalResults = UBound(IPResult.AddressList)
Console.WriteLine("Found a total of {0} addresses for [{1}]:",
(iTotalResults + 1).ToString, cmdArgs(0))
Console.WriteLine()
ReDim sIPs(iTotalResults)
ReDim sNames(iTotalResults)
Dim i As Integer = 0
Do While i <= UBound(IPResult.AddressList)
sIPs(i) = (IPResult.AddressList(i).ToString())
Try
sNames(i) =
HostLookup.GetHostByAddress(sIPs(i)).HostName.ToString
Catch ex As Sockets.SocketException
If sNames(i) = vbNullString Then sNames(i) = "none"
End Try
Console.WriteLine("{0}.{1}{2}{3}({4})", (i + 1).ToString, vbTab,
sIPs(i), vbTab, sNames(i))
i += 1
Loop
End Sub
End Module
Alternatively you can download it from Planet Source Code at:
http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=1287
-L