I want to get the local IP-Address from any Windows device. It works fine for my Desktop-PC. But when I try to get the IP of my laptop or my surface I always get 123.123.123.123
.
foreach (NetworkInterface nInterface in NetworkInterface.GetAllNetworkInterfaces()) {
if (nInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet && nInterface.OperationalStatus == OperationalStatus.Up)
foreach (var ip in nInterface.GetIPProperties().UnicastAddresses)
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
return ip.Address;
}
return IPAddress.Parse("123.123.123.123"); // Only for visualization, that none of the addresses fulfilled the conditions
Do I need to add another NetworkInterfaceType?