I have 900+ IP address ranges from the Microsoft Azure datacentres (http://www.microsoft.com/en-us/download/confirmation.aspx?id=41653) and I want to find out if an IP address is coming from one of these addresses. I've converted it into a single list which could be stored in a text file.
So: is it more costly to loop through each address and use ip2long() such as point 3 here (https://mebsd.com/coding-snipits/php-ipcalc-coding-subnets-ip-addresses.html) OR is it better to convert all IP addresses in the range, store them in a database and then look them up? If the latter, how does one achieve this (i.e. convert a range to all IP addresses within it)?
The key for me is that it must be fast as we'll be checking this fairly often.
Example IP addresses/ranges:
40.112.124.0/24
65.52.128.0/19
94.245.97.0/24
104.47.169.0/24
104.214.240.0/24
137.116.192.0/19
157.55.8.96/27
157.55.8.128/27
157.55.8.160/28
168.63.0.0/19