Results 1 to 12 of 12

Thread: [2005] MAC Address -> IP Address

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: [2005] MAC Address -> IP Address

    Quote Originally Posted by kasracer
    gigemboy, you can have multiple network adapters on 1 computer which is probably why the IP addresses are an array.
    Yeah but it loops for all network interfaces. Each network interface has the property that is an array. You wont have 2 IP's for 1 network interface... as far as I know... unless maybe 1 will return the regular IP and loopback IP?

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] MAC Address -> IP Address

    Quote Originally Posted by gigemboy
    Yeah but it loops for all network interfaces. Each network interface has the property that is an array. You wont have 2 IP's for 1 network interface... as far as I know... unless maybe 1 will return the regular IP and loopback IP?
    The loopback address is implimented in the device's drivers. It shouldn't count that as a second IP.

    It's probably related to network cards like this one: http://www.newegg.com/Product/Produc...82E16833106217
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    Re: [2005] MAC Address -> IP Address

    you don't really need to add references to the ManagementObject, you could always use a simple API call ( *** just as an alternative *** )
    on your local network you can use the SendARP API, you can also use this for any network interfaces on your own machine.
    here's a quick example i bunged together for you , it's based on a few C# examples floating about, i just modified it to work in VB.NET...
    VB Code:
    1. [COLOR=Blue]Private Declare[/COLOR] [COLOR=Blue]Function[/COLOR] inet_addr [COLOR=Blue]Lib[/COLOR] "ws2_32.dll" ([COLOR=Blue]ByVal[/COLOR] cp [COLOR=Blue]As String[/COLOR]) [COLOR=Blue]As[/COLOR] Int32
    2.     [COLOR=Blue]Private Declare Function[/COLOR] SendARP [COLOR=Blue]Lib[/COLOR] "IPHLPAPI.dll" ([COLOR=Blue]ByVal[/COLOR] DestIP [COLOR=Blue]As Integer[/COLOR], [COLOR=Blue]ByVal[/COLOR] SrcIP [COLOR=Blue]As[/COLOR] Int32, [COLOR=Blue]ByVal[/COLOR] pMacAddr [COLOR=Blue]As Byte[/COLOR](), [COLOR=Blue]ByRef [/COLOR] PhyAddrLen [COLOR=Blue]As[/COLOR] Int32) [COLOR=Blue]As[/COLOR] Int32
    3.  
    4.     [COLOR=Blue]Private Sub[/COLOR] Button1_Click([COLOR=Blue]ByVal[/COLOR] sender [COLOR=Blue]As[/COLOR] System.Object, [COLOR=Blue]ByVal[/COLOR] e [COLOR=Blue]As[/COLOR] System.EventArgs) [COLOR=Blue]Handles[/COLOR] Button1.Click
    5.         [COLOR=Green]'/// buffer to receive the MacAddress into...[/COLOR]
    6.         [COLOR=Blue]Dim[/COLOR] buf(6) [COLOR=Blue]As Byte[/COLOR]
    7.         [COLOR=Green]'/// specify your ip to check here *** remember to add Imports System.NET at the top of the code window *** ...[/COLOR]
    8.         [COLOR=Blue]Dim[/COLOR] ip [COLOR=Blue]As[/COLOR] IPAddress = IPAddress.Parse("192.168.0.4")
    9.  
    10.         [COLOR=Blue]If[/COLOR] SendARP(BitConverter.ToInt32(IPAddress.Parse("192.168.0.4").GetAddressBytes, 0), 0, buf, 6) = 0 [COLOR=Blue]Then[/COLOR]
    11.             Console.WriteLine(BitConverter.ToString(buf, 0, 6))
    12.         [COLOR=Blue]End If[/COLOR]
    13.  
    14.     [COLOR=Blue]End Sub[/COLOR]
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width