当前位置:网站首页>C# Get network card information NetworkInterface IPInterfaceProperties
C# Get network card information NetworkInterface IPInterfaceProperties
2022-07-31 13:36:00 【dusk and starry sky】
under System.Net.NetworkInformation
1: The NetworkInterface class, which provides configuration and statistics for the network adapter.
It can be used to detect how many network cards are configured on the machine, which network connections are available, and obtain the MAC address and speed of the network card.
This class encapsulates data for a network interface (also called an adapter) on the local computer.There is no need to create an instance of this class; the GetAllNetworkInterfaces method returns an array containing one instance of this class for each network interface on the local computer.
2: The IPInterfaceProperties class provides information about network interfaces that support Internet Protocol version 4 (IPv4) or Internet Protocol version 6 (IPv6).
This class can be used to access configuration and address information for IPv4 or IPv6 capable network interfaces.Do not create instances of this class, these will be returned by the GetIPProperties method.
To access IPv4-specific properties, use the object returned by the GetIPv4Properties method.To access IPv6 specific properties, use the object returned by the GetIPv6Properties method
void Start () {//Network card information classNetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();foreach (NetworkInterface adapt 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/en-us/library/system.net.networkinformation.networkinterface%28v=vs.110%29.aspx
IPInterfaceProperties>>> https://msdn.microsoft.com/en-us/library/system.net.networkinformation.ipinterfaceproperties%28v=vs.110%29.aspx
边栏推荐
- 代码随想录笔记_哈希_454四数相加II
- 【牛客刷题-SQL大厂面试真题】NO3.电商场景(某东商城)
- ECCV 2022 | 机器人的交互感知与物体操作
- 技能大赛训练题:交换机虚拟化练习
- C语言基础练(九九乘法表)与打印不同星号图案
- 技能大赛训练题:交换机的远程管理
- Save and load numpy matrices and vectors, and use the saved vectors for similarity calculation
- 图像大面积缺失,也能逼真修复,新模型CM-GAN兼顾全局结构和纹理细节
- C# control ToolStripProgressBar usage
- Verilog——基于FPGA的贪吃蛇游戏(VGA显示)
猜你喜欢
随机推荐
浏览器被hao360劫持解决办法
线程池的使用二
AI cocoa AI frontier introduction (7.31)
基于高阶微分器的无模型滑模控制器及其在自动电压调节器中的应用
ECCV2022: Recursion on Transformer without adding parameters and less computation!
深度剖析 Apache EventMesh 云原生分布式事件驱动架构
自制的数据库安全攻防题,相关靶机自己制作
Use of C# Assembly
All-round visual monitoring of the Istio microservice governance grid (microservice architecture display, resource monitoring, traffic monitoring, link monitoring)
SAP e-commerce cloud Spartacus SSR Optimization Engine execution sequence of several timeouts
Error IDEA Terminated with exit code 1
/run/NetworkManager占用空间过大
LeetCode·304竞赛·6132·使数组中所有元素都等于零·模拟·哈希
Sliding window method to segment data
「面经分享」西北大学 | 字节 生活服务 | 一面二面三面 HR 面
技能大赛训练题: 子网掩码划分案例
PartImageNet物体部件分割(Semantic Part Segmentation)数据集介绍
Istio微服务治理网格的全方面可视化监控(微服务架构展示、资源监控、流量监控、链路监控)
Introduction to using NPM
Usage of += in C#









