public static bool IsLocalIpAddress(string host)
{
try
{
IPAddress[] hostIPs = Dns.GetHostAddresses(host);
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
foreach (IPAddress hostIP in hostIPs)
{
if (IPAddress.IsLoopback(hostIP)) return true;
foreach (IPAddress localIP in localIPs)
{
if (hostIP.Equals(localIP)) return true;
}
}
}
catch { }
return false;
}