using System.Net.NetworkInformation;
public static void Main()
public static void ShowNetworkInterfaces()
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
Console.WriteLine("Interface information for {0}.{1} ", computerProperties.HostName, computerProperties.DomainName);
if (nics == null || nics.Length < 1)
Console.WriteLine(" No network interfaces found.");
Console.WriteLine(" Number of interfaces .................... : {0}", nics.Length);
foreach (NetworkInterface adapter in nics)
IPInterfaceProperties properties = adapter.GetIPProperties();
Console.WriteLine(adapter.Description);
Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length, '='));
Console.WriteLine(" Interface type .......................... : {0}", adapter.NetworkInterfaceType);
PhysicalAddress address = adapter.GetPhysicalAddress();
Console.WriteLine(string.Format("ToString Address: {0}", address.ToString()));
Console.Write(" Physical address ........................ : ");
byte[] bytes = address.GetAddressBytes();
for (int i = 0; i < bytes.Length; i++)
Console.Write("{0}", bytes[i].ToString("X2"));
if (i != bytes.Length - 1)