Class NetworkInterface
Provides information about network interfaces and enables applications to control them.
Inherited Members
Namespace: System.Net.NetworkInformation
Assembly: System.Net.dll
Syntax
public class NetworkInterface
Remarks
This class is exclusive of nanoFramework and it does not exist on the UWP API.
Constructors
| Improve this Doc View SourceNetworkInterface(Int32)
Initializes a new instance of the NetworkInterface class.
Declaration
protected NetworkInterface(int interfaceIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | interfaceIndex |
Properties
| Improve this Doc View SourceIPv4Address
Holds the IP v4 address of the network interface.
Declaration
public string IPv4Address { get; }
Property Value
Type | Description |
---|---|
String |
IPv4DnsAddresses
Holds the IPv4 DNS server address.
Declaration
public string[] IPv4DnsAddresses { get; }
Property Value
Type | Description |
---|---|
String[] |
IPv4GatewayAddress
Contains the gateway IPv4 address.
Declaration
public string IPv4GatewayAddress { get; }
Property Value
Type | Description |
---|---|
String |
IPv4SubnetMask
Retrieves the network interface's IPv4 subnet mask.
Declaration
public string IPv4SubnetMask { get; }
Property Value
Type | Description |
---|---|
String |
IsAutomaticDnsEnabled
Retrieves a value indicating whether a network interface can obtain a DNS server address automatically. true if dynamic DNS is enabled, or false if not.
Declaration
public bool IsAutomaticDnsEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsDhcpEnabled
Gets a value specifying whether DHCP is enabled for this network interfaces. true if DHCP is enabled, or false if not.
Declaration
public bool IsDhcpEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
NetworkInterfaceType
Retrieves a value specifying the type of network interface being used by the device.
Declaration
public NetworkInterfaceType NetworkInterfaceType { get; }
Property Value
Type | Description |
---|---|
NetworkInterfaceType |
PhysicalAddress
Gets or sets the Media Access Control (MAC) address for a network interface.
Declaration
public byte[] PhysicalAddress { get; set; }
Property Value
Type | Description |
---|---|
Byte[] |
SpecificConfigId
The ID of the associated configuration, if any. To be used as the foreign key of that configuration.
Declaration
public uint SpecificConfigId { get; set; }
Property Value
Type | Description |
---|---|
UInt32 |
Remarks
If there is no configuration associated it reads as MaxValue.
Methods
| Improve this Doc View SourceEnableAutomaticDns()
Enables a network interface to obtain a DNS server address automatically.
Declaration
[Obsolete("This method will be removed in a future version. Using automatic DNS it's part of DHCP configuration and can't be used as an individual operation.")]
public void EnableAutomaticDns()
EnableDhcp()
Enables the Dynamic Host Configuration Protocol (DHCP) for service with this network interface.
Declaration
public void EnableDhcp()
EnableStaticIP(String, String, String, String, String, String)
Enables an application to set and use a static IPv4 and IPv6 address.
Declaration
public void EnableStaticIP(string ipv4Address, string ipv4subnetMask, string ipv4gatewayAddress, string ipv6Address, string ipv6SubnetMask, string ipv6GatewayAddress)
Parameters
Type | Name | Description |
---|---|---|
String | ipv4Address | Holds the IPv4 address to use. |
String | ipv4subnetMask | Contains the IPv4 address's subnet mask. |
String | ipv4gatewayAddress | Specifies the IPv4 address of the gateway. |
String | ipv6Address | Holds the IPv6 address to use. |
String | ipv6SubnetMask | Contains the IPv6 address's subnet mask. |
String | ipv6GatewayAddress | Specifies the IPv6 address of the gateway. |
EnableStaticIPv4(String, String, String)
Enables an application to set and use a static IPv4 address.
Declaration
public void EnableStaticIPv4(string ipv4Address, string ipv4SubnetMask, string ipv4GatewayAddress)
Parameters
Type | Name | Description |
---|---|---|
String | ipv4Address | Holds the IPv4 address to use. |
String | ipv4SubnetMask | Contains the IPv4 address's subnet mask. |
String | ipv4GatewayAddress | Specifies the IPv4 address of the gateway. |
EnableStaticIPv4Dns(String[])
Enables a network interface to use a specific DNS server IPv4 address.
Declaration
public void EnableStaticIPv4Dns(string[] dnsAddresses)
Parameters
Type | Name | Description |
---|---|---|
String[] | dnsAddresses | Holds the DNS server address. |
EnableStaticIPv6(String, String, String)
Enables an application to set and use a static IPv6 address.
Declaration
public void EnableStaticIPv6(string ipv6Address, string ipv6SubnetMask, string ipv6GatewayAddress)
Parameters
Type | Name | Description |
---|---|---|
String | ipv6Address | Holds the IPv6 address to use. |
String | ipv6SubnetMask | Contains the IPv6 address's subnet mask. |
String | ipv6GatewayAddress | Specifies the IPv6 address of the gateway. |
EnableStaticIPv6Dns(String[])
Enables a network interface to use a specific DNS server IPv6 address.
Declaration
public void EnableStaticIPv6Dns(string[] dnsAddresses)
Parameters
Type | Name | Description |
---|---|---|
String[] | dnsAddresses | Holds the DNS server address. |
GetAllNetworkInterfaces()
Retrieves an array of all of the device's network interfaces.
Declaration
public static NetworkInterface[] GetAllNetworkInterfaces()
Returns
Type | Description |
---|---|
NetworkInterface[] | An array containing all of the device's network interfaces. |
GetIsNetworkAvailable()
Indicates whether any network connection is available.
Declaration
public static extern bool GetIsNetworkAvailable()
Returns
Type | Description |
---|---|
Boolean | true if a network connection is available; otherwise, false. |
Remarks
A network connection is considered to be available if any network interface is marked "up" and is not a loopback or tunnel interface.
ReleaseDhcpLease()
Releases the DHCP lease, which releases the IP address bound to a DHCP-enabled network interface.
Declaration
public void ReleaseDhcpLease()
RenewDhcpLease()
Renews a DHCP lease, which renews the IP address on a DHCP-enabled network interface.
Declaration
public void RenewDhcpLease()