|
-
Oct 18th, 2013, 01:44 PM
#1
Thread Starter
Member
[RESOLVED] Finding All IP addresses on a local network taking too long
I am trying to enumerate all of the IP addresses on my local network using SendARP, like so:
For nIndex = 1 To 254
uIPAddr.s_b4 = CByte(nIndex) 'fourth byte of the IP address
LSet uIPAddrCompat = uIPAddr ' Convert 4 bytes into 1 long.
nMacAddrLen = 8 ' Indicate that we are allocating a buffer with 8 bytes.
' Try to find the MAC address for this IP.
If SendARP(uIPAddrCompat.ul, 0&, uMacAddr, nMacAddrLen) = 0 Then
' MAC addresses are 6 bytes long.
If nMacAddrLen = 6 Then
vasLocalIP(3) = CStr(nIndex)
j = j + 1
Text1.Text = Text1.Text & j & ". " & Join(vasLocalIP, ".") & " - " & MacAddrString(uMacAddr, nMacAddrLen) & vbCrLf
DoEvents
End If
End If
Next nIndex
This acts very quickly with IP addresses that are on the network, but far too slow to be practical for IP addresses that are not being used. To go through all 254 possibilities takes a minute or two. Maybe more - I lost interest in timing it.
Is there a faster way? Or is there a way to speed this method up? I was able to enumerate all of the computers on my network with NetServerEnum. Is there a similarly easy way to enumerate all IP addresses?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|