in reply to finding if an ip is in a subnet
Even with 4500 IPs and 1500 subnets, it would just take a bit of time to run through two nested loops to obtain an answer that is presumably needed only once. A fairly brute force approach should work nicely, and the total memory requirement will be quite small.