I have a lot of IP ranges of different providers. For example
P1: 192.168.1.10 - 192.168.1.50, 192.168.2.16 - 192.168.2.49,
P2: 17.36.15.34 - 17.36.15.255,
P3: .
In my opinion best solution would be sorted set.
To insert range use ZADD.
To member
assign range_name.
To score
assign highest value in range.
ZADD ip_table 3232235826 some_name
Then for finding range use ZRANGEBYSCORE with user_ip as min_value and limit = 1.
ZRANGEBYSCORE ip_table user_ip +inf LIMIT 0 1
It will find range with smallest ip at endpoint that is greater than or equal to user_ip.