CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    440

    Scan NIC for IPs

    When I check my system for present NICS ...
    Code:
    cbNics.Items.Clear();
    
    NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
    if (nics == null || nics.Length < 1)
    {
      cbNics.Items.Add("-- No network interfaces found --");
    }
    
    foreach (NetworkInterface adapter in nics)
    {
      cbNics.Items.Add(adapter.Description); 
    }
    I would then like to select a specific NIC and scan the attached network for all present IP addresses.

    Any suggestion how to do this ?

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    210

    Re: Scan NIC for IPs

    Code:
    nics[index]
    ???
    Last edited by MNovy; November 25th, 2008 at 04:06 AM.

  3. #3
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    440

    Re: Scan NIC for IPs

    Ok, I know how to select a specific nic from the returned collection !

    My question actually is , starting from this NetworkInterface object to scan the attached network for IP addresses. I want to find out what devices are hooked up to the nic.

  4. #4
    Join Date
    Aug 2007
    Location
    Birmingham, UK
    Posts
    360

    Re: Scan NIC for IPs

    There is no fail safe method to detect all devices attached to a network. Still, you can use the IP address and netmask of the NIC to find out what the range of possible IP addresses is for the network that NIC is connected to. Then for each individual NIC in that range you can use ARP to find out if there is an active NIC on the network.

    You will of course not receive any answer from devices that are currently off (but still may have a fixed IP address asigned to them).

    Please note - one NIC may have multiple ranges of addresses for different subnets it is connected to.

    In any case, this is not something I have ever needed to do, but this is probably how I would go about it..

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

Featured