如何查找给定IP地址的所有网络接口。 [英] How to find all Network Interfaces for a given ip address.
本文介绍了如何查找给定IP地址的所有网络接口。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何查找给定IP地址的所有网络接口。
现在,我正在使用下面的代码来确定它,但它总是为本地计算机提供它,我想为给定的IP地址实现它。
NetworkInterface [] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach(适配器中的NetworkInterface适配器)
{
IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
IPAddressCollection dnsServers = adapterProperties.DnsAddresses;
if (dnsServers.Count> 0 )
{
Console.WriteLine( Adapter Id ....: + adapter.Id) ;
Console.WriteLine( 适配器说明....: + adapter.Description) ;
Console.WriteLine( 适配器名称....: + adapter.Name) ;
Console.WriteLine( 网络接口类型....: + adapter.NetworkInterfaceType的ToString());
Console.WriteLine( Adapter Speed ....: + adapter.Speed) ;
Console.WriteLine( OperationalStatus ....: + adapter.OperationalStatus);
Console.WriteLine( Adapter SupportsMulticast ....: + adapter.SupportsMulticast) ;
}
}
请建议..........
解决方案
这是您的解决方案。请点击这里链接
http://stackoverflow.com/questions/9855230/how-to-get-the-network-interface-and-its-right-ipv4-address [ ^ ]
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..........
解决方案
Here is your solution. click here on link please
http://stackoverflow.com/questions/9855230/how-to-get-the-network-interface-and-its-right-ipv4-address[^]
这篇关于如何查找给定IP地址的所有网络接口。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文