Click to See Complete Forum and Search --> : Scan NIC for IPs


zvenny
November 25th, 2008, 02:09 AM
When I check my system for present NICS ...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 ?

MNovy
November 25th, 2008, 03:02 AM
nics[index] ???

zvenny
November 25th, 2008, 04:45 AM
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.

Edders
November 25th, 2008, 08:49 AM
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..