title: .NET get active Ethernet IPAddress
body: <p>I am looking to get the active IPAddress in .net, in this case the address associated with the Ethernet adapter.</p>
  
  <p>Now I know I can get a list of IPs currently assigned to the machine using:</p>
  
  <pre><code>IPHostEntry entry = Dns.GetHostEntry(Dns.GetHostName());
  </code></pre>
  
  <p>And I know I can get a good deal of information about my different Network Interfaces using:</p>
  
  <pre><code>NetworkInterface[] networks = NetworkInterface.GetAllNetworkInterfaces();
  </code></pre>
  
  <p>I can determine which of those interfaces is my Ethernet interface using the NetworkInterfaceType enum and whether or not the interface is "Up", but I can't seem to find a way to tie this NetworkInterface to the corresponding IPAddress.  From within the NetworkInterface class I can only see how to get things like the Anycast Addresses or the Gateway Addresses, but nothing that can help me narrow down which is my Ethernet IP.</p>
  
  <p>Does anyone know a way to do this, whether it be simple or complicated?</p>
  
  <p>EDIT:
  For instance netstat or tracert on the command line can give all active network connections.  It seems odd to me that .net would not have something similar to this it seems completely unnessary to me to parse command line result. 
  Something like GetBestInterface() seems useful but it will only return on IP that has access to a given other IP.  Again, not very versatile.</p>
  
  <p>If there is no other way to use C# to get active IPAdresses then so be it, I will use the command line, but it really just seems like something that a popular programming language should be able to do.  In fact, if anyone has a C++ or C solution that I could hook up to my C# app that would work as well.</p>