当前位置:网站首页>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
边栏推荐
- C#使用NumericUpDown控件
- C语言基础练(九九乘法表)与打印不同星号图案
- csdn发文助手问题
- [CPU Design Practice] Simple Pipeline CPU Design
- Error IDEA Terminated with exit code 1
- Solution for browser hijacking by hao360
- 技能大赛训练题:交换机虚拟化练习
- EasyMock日记1[通俗易懂]
- How to quickly split and merge cell data in Excel
- 【蓝桥杯选拔赛真题46】Scratch磁铁游戏 少儿编程scratch蓝桥杯选拔赛真题讲解
猜你喜欢

【蓝桥杯选拔赛真题46】Scratch磁铁游戏 少儿编程scratch蓝桥杯选拔赛真题讲解

深度剖析 Apache EventMesh 云原生分布式事件驱动架构

Edge Cloud Explained in Simple Depth | 4. Lifecycle Management

PHP Serialization: eval

PartImageNet物体部件分割(Semantic Part Segmentation)数据集介绍

go使用makefile脚本编译应用

Spark Learning: Add Custom Optimization Rules for Spark Sql

浏览器被hao360劫持解决办法

C# control StatusStrip use

20.nn.Module
随机推荐
中望3D 2023正式发布,设计仿真制造一体化缩短产品开发周期
LeetCode·304竞赛·6132·使数组中所有元素都等于零·模拟·哈希
ICML2022 | 面向自监督图表示学习的全粒度自语义传播
C# List Usage List Introduction
0X7FFFFFFF,0X80000000「建议收藏」
Spark Learning: Add Custom Optimization Rules for Spark Sql
Selenium自动化测试之Selenium IDE
Adding data nodes and decommissioning data nodes in the cluster
DELL SC compellent 康贝存储系统怎么抓取配置信息
EXCEL如何快速拆分合并单元格数据
[CPU Design Practice] Simple Pipeline CPU Design
Flutter keyboard visibility
The importance of strategic offensive capability is much higher than strategic defensive capability
推荐系统-召回阶段-2013:DSSM(双塔模型)【Embedding(语义向量)召回】【微软】
抓住金三银四的尾巴,解锁程序员面试《刷题神器》
Error IDEA Terminated with exit code 1
LeetCode只出现一次的数字
IDEA找不到Database解决方法
Invalid bound statement (not found)出现的原因和解决方法
Edge Cloud Explained in Simple Depth | 4. Lifecycle Management