2

How to find all Network Interfaces for a given ip address.

Right now,I am using below code to determine it but it is always giving it for local computer and I want to achieve it for given IP address.

NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{

    IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
    IPAddressCollection dnsServers = adapterProperties.DnsAddresses;
    if (dnsServers.Count > 0)
    {

        Console.WriteLine("Adapter Id .... : " + adapter.Id);
        Console.WriteLine("Adapter Description .... : " + adapter.Description);
        Console.WriteLine("Adapter Name .... : " + adapter.Name);
Console.WriteLine("Network Interface Type .... : " + adapter.NetworkInterfaceType.ToString());
        Console.WriteLine("Adapter Speed .... : " + adapter.Speed);
        Console.WriteLine("OperationalStatus .... : " + adapter.OperationalStatus);
        Console.WriteLine("Adapter SupportsMulticast .... : " + adapter.SupportsMulticast);

        }
    }

Please suggest.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Ajeet
  • 21
  • 2
  • Well obviously it only works for the local machine - you're asking for NICes of the local machine. Why do you want to know the NICes of a remote computer? – Luaan Jul 02 '14 at 07:26
  • (this question isn't really a duplicate - it doesn't ask for NICes on the local computer) – Luaan Jul 02 '14 at 07:27
  • Use WMI queries to query data like this from remote machines. – Sean Airey Jul 02 '14 at 08:10
  • Hi Sean, I am using WMI queries to achieve it but most of property values are coming for corresponding key. – Ajeet Jul 03 '14 at 08:56

0 Answers0