Ip ranges/CIDR

,

Hi - sorry for the lack of response, this wandered quite a bit from IP ranges, and looks like a golang question - and I am not a golang expert.

If so, would you like me to re-ask this question in golang, or can you do it?

Thanks

OK we did implement this for IPV4 addresses

As of now there is still no support for range queries between 2 bins We can either do from start or end

0.0.0.0 - requestedIP OR requestedIP - 255.255.255.255

Even sub ranges don’t work for most db’s We had a look at Maxmind’s data and the ranges are inconsistent as in some have 0 ips between start and end and others have a million

For now we have gone with a very basic storage pattern i.e Store individual IP number from start and end inclusive as individual records in the set there is a single bin which contains an encoded bytes array which contains all the required columns for geolocation data

eg

IP Number location 1234567 {Encoded bytes array of Country,State,city,zip etc}

Average query time is sub 5 ms for this storage pattern for ~50 mil requests/hour

Something to consider -

  1. We did not store the IP’s from all over the world, only the countries we require as storage will be an issue assuming average record size comes out to be ~250 bytes
  2. This will not work for IPV6 (No of possible IPV6 >>>>>> IPV4)

This thread is almost 10 years old! @Jaskaran-Blockboard could you start a new thread with your request. I think your request is now possible if you store your ipv4 addresses as integers and create a secondary index on them. Our integers are 8 bytes, so this method wouldn’t work for 16 byte IPv6, but you may be able to do something like index the high 8 bytes and use a expression to filter the lower 8 bytes.

I just realised how old the thread was! my bad.

IPV4 isn’t really an issue at this moment IPV6 is

Considering the no of possibilities for IPV6 addresses even while considering the high 8 bytes. I cannot store all the IPV6 numbers individually. Storage will run in million of GBs. So what i am looking for is the ability to use a IP in Range filter query similar to how we have geo containing point queries for GEOJSON data.

I cannot find any such functionality in the latest docs

Just to get clarity, the solution is:

Record has 4 bins.
Bin 1:  IPV6 high 8 bytes  - Build a numeric Secondary Index on this Bin.
Bin 2:  Low 8 bytes - Start range of these 8 high bytes of Bin 1
Bin 3:  Low 8 bytes - End range of these 8 high bytes on Bin 1
Bin 4:  Whatever data you want to tie to this range
Search:  If a given IPV6 address is in this range: 
Find records that match (Filter.equal) the high 8 bytes (Bin1) using SI query, then use Expressions to match low 8 bytes, in the range. 
If matches, return Bin4 data.

Not Exactly

Take a sample IPV6 range for a location where we only consider the first 
64bits(8 bytes) of an IPV6 address.

The remaining 8 bytes are inconsequential for my dataset

Start Range             End Range
2001:410:a004:f0c0,     2001:410:a007:ffff          {Some Location}     
          
Record has 3 bins
Bin 1 :  2001:410:a004:f0c0(Start Range)
Bin 2 :  2001:410:a007:ffff (End Range)
Bin 3 :  Location

Then

Search:  If a given IPV6 address is in this range: 
Find record(Singular) for which the request IPV6 lies in this range

Eg 
If Only the above record exists in the Set
2001:410:a005:ffff -> Will be in this range and will return the above record
2001:410:a008:ffff -> Will return empty

I understand a single secondary index can be used with bin 1 but it only allows greater, equal or lesser queries from what i have been able to find in the docs so far.

I also read in a different post that currently only 1 secondary index per query is supported.

This will not work for us as we need a sub 10 ms response.