using System;
using System.Linq;
using System.Net.NetworkInformation;
namespace ConsoleApplication1
{
internal class Program
{
private static void Main(string[] args)
{
foreach (var nic in NetworkInterface.GetAllNetworkInterfaces().Where(nic => nic.OperationalStatus == OperationalStatus.Up)) {
Console.WriteLine("{0} has an address of {1}", nic.NetworkInterfaceType, nic.GetPhysicalAddress());
}
Console.ReadKey();
}
}
}
This console app returns all the interfaces that are up...
private static string[] GetUpInterfaces()
{
return
NetworkInterface.GetAllNetworkInterfaces()
.Where(nic => nic.OperationalStatus == OperationalStatus.Up)
.Select(xx => xx.GetPhysicalAddress().ToString()).ToArray();
}