How to check if certain IP address is part of a range?

I need to check if $ip_address belongs to the IP addresses ranges I have.

The only clumsy way that I get to go is using nmap to extract all addresses to the file and use grep to check if IP address belongs to the CIDR.

But addresses nmaping takes too long, so this means I’m doing this task incorrectly.