public static IEnumerable<string> GetIP() { string strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName); foreach (IPAddress entry in ipEntry.AddressList) { if (entry.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) yield return entry.ToString(); } }