Getting all available network interface using NetworkInterface namespace

By using the NetworkInformation namespace
you can get all of the available network interfaces on the current machine.
This is very useful for  applications that are network aware 
or that require to configure the network adapters.
using System.Net.NetworkInformation;
   1:  //Iterate to all available network interfaces
   2:  foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces())
   3:  {
   4:      // Filter to load only configurable interfaces
   5:      if (netInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet |
   6:           netInterface.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
   7:      {
   8:         //Use the ff as strings, add to a collection or a list
   9:          netInterface.Name.ToString();
  10:          netInterface.Description.ToString();
  11:      }
  12:  }

The above snippet came from a little project that I wrote for me and my Amy that configures our wireless and cabled adapters. Because we both have laptops that connects to both of our office wireless, LAN on their conference (no wireless signal there), wireless in the condo, wireless at Bataan (ssshhh its free, but we need to configure your DNS to SMART BRO :P, it seems that their neighbor has DHCP but did not configured / or has hidden the DNS) 


Published by


John is currently creating digital assets that protects people and their future, a technical trainer and a full time geek specializing on development and deployment of innovations created with .NET framework on Windows platform as well as Windows infrastructure projects. He is the primary contact of the Philippine Windows Users Group, a contributor at the Microsoft Philippines Community forums and regularly conducts community sessions as well as other Microsoft technology events. John owns the Busy Saving The World Techblog.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s