This project provides examples for enriching cidr block data to make it easier to query in MongoDB
CIDR blocks inserted are: (Indexed on ipAddress - ascending)
192.168.100.14/22
192.168.100.14/16
192.168.100.14/24
192.168.100.14/4
192.168.100.13/28
192.168.100.14/16
Case-1
Searching for IP - 192.168.100.15 is not returning any. Expected result is 192.168.100.13/28 as this is smaller block (16 IPs) & contains IP=192.168.100.15
> db.subscriber.find({"ipAddress":{$regex:'^192.168.100.15.*'}}).sort({"ipAddress":1}).limit(1)
Case-2
Searching for IP - 192.168.101.14 is not returning any. Expected result is 192.168.100.14/22 as this is smaller block(1024 IPs) & contains IP=192.168.101.14
> db.subscriber.find({"ipAddress":{$regex:'^192.168.101.14.*'}}).sort({"ipAddress":1}).limit(1)