Table of Contents

Class NetworkInterface

Namespace
System.Net.NetworkInformation
Assembly
System.Net.dll

Provides information about network interfaces and enables applications to control them.

public class NetworkInterface
Inheritance
NetworkInterface
Inherited Members
Extension Methods

Remarks

This class is exclusive of nanoFramework and it does not exist on the UWP API.

Constructors

NetworkInterface(int)

Initializes a new instance of the NetworkInterface class.

protected NetworkInterface(int interfaceIndex)

Parameters

interfaceIndex int

Properties

IPv4Address

Holds the IP v4 address of the network interface.

public string IPv4Address { get; }

Property Value

string

IPv4DnsAddresses

Holds the IPv4 DNS server address.

public string[] IPv4DnsAddresses { get; }

Property Value

string[]

IPv4GatewayAddress

Contains the gateway IPv4 address.

public string IPv4GatewayAddress { get; }

Property Value

string

IPv4SubnetMask

Retrieves the network interface's IPv4 subnet mask.

public string IPv4SubnetMask { get; }

Property Value

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.

public bool IsAutomaticDnsEnabled { get; }

Property Value

bool

IsDhcpEnabled

Gets a value specifying whether DHCP is enabled for this network interfaces. true if DHCP is enabled, or false if not.

public bool IsDhcpEnabled { get; }

Property Value

bool

NetworkInterfaceType

Retrieves a value specifying the type of network interface being used by the device.

public NetworkInterfaceType NetworkInterfaceType { get; }

Property Value

NetworkInterfaceType

PhysicalAddress

Gets or sets the Media Access Control (MAC) address for a network interface.

public byte[] PhysicalAddress { get; set; }

Property Value

byte[]

SpecificConfigId

The ID of the associated configuration, if any. To be used as the foreign key of that configuration.

public uint SpecificConfigId { get; set; }

Property Value

uint

Remarks

If there is no configuration associated it reads as MaxValue.

Methods

EnableAutomaticDns()

Enables a network interface to obtain a DNS server address automatically.

[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.

public void EnableDhcp()

EnableStaticIP(string, string, string, string, string, string)

Enables an application to set and use a static IPv4 and IPv6 address.

public void EnableStaticIP(string ipv4Address, string ipv4subnetMask, string ipv4gatewayAddress, string ipv6Address, string ipv6SubnetMask, string ipv6GatewayAddress)

Parameters

ipv4Address string

Holds the IPv4 address to use.

ipv4subnetMask string

Contains the IPv4 address's subnet mask.

ipv4gatewayAddress string

Specifies the IPv4 address of the gateway.

ipv6Address string

Holds the IPv6 address to use.

ipv6SubnetMask string

Contains the IPv6 address's subnet mask.

ipv6GatewayAddress string

Specifies the IPv6 address of the gateway.

EnableStaticIPv4(string, string, string)

Enables an application to set and use a static IPv4 address.

public void EnableStaticIPv4(string ipv4Address, string ipv4SubnetMask, string ipv4GatewayAddress)

Parameters

ipv4Address string

Holds the IPv4 address to use.

ipv4SubnetMask string

Contains the IPv4 address's subnet mask.

ipv4GatewayAddress string

Specifies the IPv4 address of the gateway.

EnableStaticIPv4Dns(string[])

Enables a network interface to use a specific DNS server IPv4 address.

public void EnableStaticIPv4Dns(string[] dnsAddresses)

Parameters

dnsAddresses string[]

Holds the DNS server address.

EnableStaticIPv6(string, string, string)

Enables an application to set and use a static IPv6 address.

public void EnableStaticIPv6(string ipv6Address, string ipv6SubnetMask, string ipv6GatewayAddress)

Parameters

ipv6Address string

Holds the IPv6 address to use.

ipv6SubnetMask string

Contains the IPv6 address's subnet mask.

ipv6GatewayAddress string

Specifies the IPv6 address of the gateway.

EnableStaticIPv6Dns(string[])

Enables a network interface to use a specific DNS server IPv6 address.

public void EnableStaticIPv6Dns(string[] dnsAddresses)

Parameters

dnsAddresses string[]

Holds the DNS server address.

GetAllNetworkInterfaces()

Retrieves an array of all of the device's network interfaces.

public static NetworkInterface[] GetAllNetworkInterfaces()

Returns

NetworkInterface[]

An array containing all of the device's network interfaces.

GetIsNetworkAvailable()

Indicates whether any network connection is available.

public static bool GetIsNetworkAvailable()

Returns

bool

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.

public void ReleaseDhcpLease()

RenewDhcpLease()

Renews a DHCP lease, which renews the IP address on a DHCP-enabled network interface.

public void RenewDhcpLease()