There is a standard way and it's involves using IPSet, which was a problem in the first place. IPSet must compute all addresses to perform intersection.