There is probably more than one way but I think I'd go for converting the network address and netmask to integers (you can do that manually using evals; there is also TA-ipconvert but I hever tried it) and calculating start 32-bit int and end 32-bit int. Then I'd use mvrange to generate all numbers from those ranges. EDIT: oh, I noticed you already have start and end ip so you might just convert those. This solves generating base for your search. Append to that contents of your lookup with ips also converted to integers and you can do stats count by ip.
... View more