I just wrote a small IpSet library to check if the specified IP address is in a predefined range.
var set = IpSet.ParseOrDefault("192.168.0.*,10.10.1.0/24,192.168.1.1-192.168.2.30"); var result = set.Contains("192.168.1.150");
Support for both IPv4 and IPv6. Support CIDR Recording. The main job is to convert IP addresses to integers and compare them.
source share