private static bool MatchIPs(string requestIp, string restrictionIp) { var dividerIdx = restrictionIp.IndexOf('-'); if (restrictionIp.IndexOf('-') > 0) { var lower = IPAddress.Parse(restrictionIp.Substring(0, dividerIdx).Trim()); var upper = IPAddress.Parse(restrictionIp.Substring(dividerIdx + 1).Trim()); var range = new IPAddressRange(lower, upper); return range.IsInRange(IPAddress.Parse(requestIp)); } return requestIp == restrictionIp; }