当前位置:网站首页>C#获得网卡信息 NetworkInterface IPInterfaceProperties
C#获得网卡信息 NetworkInterface IPInterfaceProperties
2022-07-31 12:54:00 【黄昏和星空】
System.Net.NetworkInformation下的
1:NetworkInterface类,提供网络适配器的配置和统计信息。
可以通过它检测本机配置了多少网卡,哪些网络连接可用,获得网卡的MAC地址和速度等。
此类封装本地计算机上的网络接口(也称作适配器)的数据。不需创建此类的实例;GetAllNetworkInterfaces 方法返回一个数组,对于本地计算机上的每个网络接口,该数组中都包含一个此类的实例。
2:IPInterfaceProperties类 提供有关支持 Internet 协议版本 4 (IPv4) 或 Internet 协议版本 6 (IPv6) 的网络接口的信息。
此类可用于访问支持 IPv4 或 IPv6 的网络接口的配置和地址信息。不要创建此类的实例,这些实例将由 GetIPProperties 方法返回。
若要访问 IPv4 特定属性,请使用 GetIPv4Properties 方法返回的对象。若要访问 IPv6 特定属性,请使用 GetIPv6Properties 方法返回的对象
void Start () {
//网卡信息类
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adap in adapters)
{
Debug.Log("CardName::" + adap.Name + " /Speed::" + adap.Speed + " /MAC::" + BitConverter.ToString(adap.GetPhysicalAddress().GetAddressBytes()));
IPInterfaceProperties ipProperties = adap.GetIPProperties();
GatewayIPAddressInformationCollection gateways = ipProperties.GatewayAddresses;
foreach (var tmp in gateways)
{
Debug.Log("Gateway>>>"+tmp.Address);
}
IPAddressCollection dnsAddress = ipProperties.DnsAddresses;
foreach (IPAddress tmp in dnsAddress)
{
Debug.Log("DNS>>>" + BitConverter.ToString(tmp.GetAddressBytes()));
}
}
}
//output
NetworkInterface>>> https://msdn.microsoft.com/zh-cn/library/system.net.networkinformation.networkinterface%28v=vs.110%29.aspx
IPInterfaceProperties>>> https://msdn.microsoft.com/zh-cn/library/system.net.networkinformation.ipinterfaceproperties%28v=vs.110%29.aspx
边栏推荐
- 基于改进YOLOv5的轻量化航空目标检测方法
- 列表页优化思路
- 0X7FFFFFFF,0X80000000「建议收藏」
- SAP 电商云 Spartacus SSR Optimization Engine 几处 timeout 的执行顺序
- 【CPU设计实战】简单流水线CPU设计
- ASM外部冗余是否可以替换磁盘
- [RPI]树莓派监控温度及报警关机保护「建议收藏」
- 通过斐波那契数再谈函数递归2.0
- [core]-ARMV7-A, ARMV8-A, ARMV9-A Architecture Introduction "Recommended Collection"
- The function of SQL GROUP BY dependence
猜你喜欢

Markdown编辑器语法

Exploring Plain Vision Transformer Backbones for Object Detection 论文阅读笔记

365天挑战LeetCode1000题——Day 044 最大层内元素和 层次遍历

PHP序列化:eval

alert(1) (haozi.me)靶场练习

IDEA的database使用教程(使用mysql数据库)

【OpenCV】-边缘检测汇总示例

系统集成项目管理工程师(软考中级)知识点总结【挣值分析】【关键路径】

How does the SAP ABAP OData service support the $filter (filter) operation trial version

深入浅出边缘云 | 4. 生命周期管理
随机推荐
Markdown编辑器语法
matlab as(assert dominance)
关于我放弃考研这件事儿
尚硅谷–MySQL–基础篇(P1~P95)
Using SQL Server FOR XML and FOR JSON syntax on other RDBMSs with jOOQ
Flutter键盘可见性
架构实战营|模块8
快速学完数据库管理
[core]-ARMV7-A, ARMV8-A, ARMV9-A Architecture Introduction "Recommended Collection"
Optimization of five data submission methods
sqlalchemy 判断一个array 类型的字段是否和一个array有至少一个一致的数据
基本语法(一)
[Shader] Shader official example [easy to understand]
双非一本进字节了!!纯干货分享
SAP e-commerce cloud Spartacus SSR Optimization Engine execution sequence of several timeouts
PyQt5 rapid development and actual combat 10.1 Get city weather forecast
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
深入浅出边缘云 | 4. 生命周期管理
vivado里那些看不懂的原语
0x80070570文件或目录损坏且无法删除(0x80070091怎么删除)