如何获取LAN接口的IP地址? [英] How to get the IP Address of the LAN interface?

查看:305
本文介绍了如何获取LAN接口的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆