title: VB.NET : Grabbing and Tieing IP Addresses to Interfaces
body: <p>I would like to find a way to grab the assigned IPv4 and IPv6 addresses to different interfaces and being able to determine which interface they're tied to. </p>
  
  <p>Currently I am looping ' System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces ' and able to grab interface specific information:</p>
  
  <pre><code>        For Each nic As System.Net.NetworkInformation.NetworkInterface In System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
  
          myarr(count2, 0) = (String.Format("{0}", nic.Description))
          myarr(count2, 1) = (String.Format("{0}", nic.GetPhysicalAddress))
          myarr(count2, 2) = (String.Format("{0}", nic.OperationalStatus))
          myarr(count2, 3) = (String.Format("{0}", nic.Speed))
  
          count2 += 1
  
  
      Next
  </code></pre>
  
  <p>Through this method I can't determine a simple method to grab assigned IP Addresses unfortunately.</p>
  
  <p>The most common method that I can easily find with google-foo is to find your IP via going through something like the following:</p>
  
  <pre><code>Dim ipAdd As IPAddress = Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.First(Function(f) f.AddressFamily = Sockets.AddressFamily.InterNetwork)
  </code></pre>
  
  <p>Which is fine and dandy but I can't determine which interface is being used nor can it determine an assigned IP Address that's not going through DNS or mulitple NICS.</p>
  
  <p>I can possibly do some ghetto method of issuing a command-line command and parsing all the information out of ipconfig or getting a GUID and running through the registry but I feel like there should be an easier more effecient method.</p>
  
  <p>A good example of  what I want is the ability to produce a list like IPCONFIG where it has interface information and their designated IP Addresess, etc...</p>