Skip to content

mdg-2018/cidr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example scripts for enriching cidr block data with numeric representations of cidr blocks

This project provides examples for enriching cidr block data to make it easier to query in MongoDB

Sample:

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)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published