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: .
This is similar to what Didier Spezia proposed, but we use begin range and end range in sorted set, because there may be "gaps".
https://github.com/nmmmnu/GeoIP-Redis