如何获取LAN接口的IP地址? [英] How to get the IP Address of the LAN interface?
问题描述
我正在使用以下代码:
strHostName = Dns.GetHostName();
IPHostEntry IpEntry = Dns.GetHostByName(strHostName);
IPAddress [] AddressList = IpEntry.AddressList;
我实际上需要从这个AddressList数组中获得一个IP(仅LAN接口IP)
有什么方法可以知道此阵列中的哪个IP是LAN接口IP吗?
当我的PC同时连接到LAN网络和Internet(抛出无线适配器)时,程序仍应可以正常工作.
等待您的建议...
谢谢:)
I''m using this code:
strHostName = Dns.GetHostName();
IPHostEntry IpEntry = Dns.GetHostByName(strHostName);
IPAddress[] AddressList = IpEntry.AddressList;
I actually need one IP from this AddressList array (the LAN interface IP only)
Is there any way to know which IP in this array is the LAN interface IP ?
the program should still be working when my PC is connected to a LAN network and to the internet (throw a wireless adapter) at the same time...
waiting for your suggestions...
thanks :)
推荐答案
请参阅CodeProject中的本文查找IP地址信息
Refer to this article in CodeProject Finding IP Address Information
这篇关于如何获取LAN接口的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!