System.Net.NetworkInformation under the
The 1:networkinterface class, which provides configuration and statistics for the network adapter.
It detects how many NICs are configured on the computer, which network connections are available, and gets the MAC address and speed of the NIC.
This class encapsulates data for a network interface (also known as an adapter) on the local computer. you do not need to create an instance of this class; The Getallnetworkinterfaces method returns an array that contains an instance of this class for each network interface on the local computer.
getallnetworkinterfaces method returns an array that contains one Instance of this class for each network interface on the local computer. " > 2: 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 network interfaces that support IPV4 or IPV6. getipproperties method. " > Do not create instances of this class that 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
1 voidStart () {2 //Network card information class3networkinterface[] Adapters =networkinterface.getallnetworkinterfaces ();4 foreach(NetworkInterface ADAPinchadapters)5 {6Debug.Log ("cardname::"+ ADAP. Name +"/speed::"+ ADAP. Speed +"/mac::"+bitconverter.tostring (ADAP. Getphysicaladdress (). Getaddressbytes ()));7Ipinterfaceproperties ipproperties =ADAP. Getipproperties ();8Gatewayipaddressinformationcollection gateways =ipproperties.gatewayaddresses;9 foreach(varTmpinchgateways)Ten { OneDebug.Log ("gateway>>>"+tmp. Address); A } -Ipaddresscollection dnsaddress =ipproperties.dnsaddresses; - foreach(IPAddress tmpinchdnsaddress) the { -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
C # 's NetworkInterface ipinterfaceproperties