当前位置:网站首页>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
边栏推荐
- ECCV2022:在Transformer上进行递归,不增参数,计算量还少!
- Sliding window method to segment data
- 基于去噪自编码器的故障隔离与识别方法
- C#控件ListView用法
- TensorRT安装及使用教程「建议收藏」
- golang-gin - graceful restart
- 推荐系统-召回阶段-2013:DSSM(双塔模型)【Embedding(语义向量)召回】【微软】
- Talk about the message display mechanism on the SAP product UI
- The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
- Samba 远程命令执行漏洞(CVE-2017-7494)
猜你喜欢
MATLAB | 我也做了一套绘图配色可视化模板
C#使用ComboBox控件
The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
【蓝桥杯选拔赛真题46】Scratch磁铁游戏 少儿编程scratch蓝桥杯选拔赛真题讲解
Invalid bound statement (not found)出现的原因和解决方法
PHP Serialization: eval
C#控件StatusStrip使用
ECCV 2022 | Robotic Interaction Perception and Object Manipulation
IDEA的database使用教程(使用mysql数据库)
[CPU Design Practice] Simple Pipeline CPU Design
随机推荐
ADS与C#通信
C#控件StatusStrip使用
基于高阶微分器的无模型滑模控制器及其在自动电压调节器中的应用
All-round visual monitoring of the Istio microservice governance grid (microservice architecture display, resource monitoring, traffic monitoring, link monitoring)
C#控件 ToolStripProgressBar 用法
LeetCode·304竞赛·6132·使数组中所有元素都等于零·模拟·哈希
The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
基于神经网络的多柔性梁耦合结构振动控制
C#获得网卡信息 NetworkInterface IPInterfaceProperties
拥塞控制,CDN,端到端
Spark学习:为Spark Sql添加自定义优化规则
文本相似度计算(中英文)详解实战
selenium被反爬了怎么办?
滑窗法切分数据
报错:npm ERR code EPERM
浏览器被hao360劫持解决办法
C#控件ListView用法
ERROR 1819 (HY000) Your password does not satisfy the current policy requirements
C# control ToolStripProgressBar usage
基于去噪自编码器的故障隔离与识别方法