// 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:
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.