To select all active local IP addresses (v4), use the following C# code:
using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; // … private static IEnumerable<IPAddress> GetLocalV4Addresses() { return from iface in NetworkInterface.GetAllNetworkInterfaces() where iface.OperationalStatus == OperationalStatus.Up from address in iface.GetIPProperties().UnicastAddresses where address.Address.AddressFamily == AddressFamily.InterNetwork select address.Address; }