title: How to get IPv4 and IPv6 address of local machine?
body: <p>I am developing a windows application and I need to find the IPv4 and IPv6 address of local machine. OS can be XP or Windows 7.</p>
  
  <p>I got a solution for getting MAC address like,</p>
  
  <pre><code>string GetMACAddress()
  {
      var macAddr =
          (
              from nic in NetworkInterface.GetAllNetworkInterfaces()
              where nic.OperationalStatus == OperationalStatus.Up
              select nic.GetPhysicalAddress().ToString()
          ).FirstOrDefault();
  
      return macAddr.ToString();
  }
  </code></pre>
  
  <p>This is working in all OS. </p>
  
  <p>What is the correct way to get IPv4 and IPv6 address that work on XP and WINDOWS 7?</p>