Here I have a static reference the ranges I need to check:
private static List Ip_Range = new List()
{
\"12.144.86.0/23\",
I use the below method to determine whether a given IP Address is a public one or private/internal:
private bool IsInternalIpAddress(string ipAddress)
{
// notes: http://whatismyipaddress.com/private-ip
var internalIpRanges = Enumerable
.Range(16, 31)
.Select(i => "172.{0}.".FormatWith(i))
.Concat(new[] {"192.168.", "10.", "127."})
.ToArray();
return ipAddress.StartsWith(internalIpRanges);
}