// get the host IP addresses
var hostIPs = System.Net.Dns.GetHostAddresses("LocalHost");
// get the local computer name
var localHostName = System.Net.Dns.GetHostName();
// get the local IP addresses
var localIPs = System.Net.Dns.GetHostAddresses(localHostName);
And here’s the full example with a method to check whether an IP address is local:



