Let's suppose I have an IP 173.245.50.16, and I want to check if it falls into the Cloudflare's IP ranges. That basically comes down to:
network_address(173.245.50.16/20) == 173.245.48.0
|| network_address(173.245.50.16/22) == 103.21.244.0
|| ...
Right? Well, I'm not sure about the terminology here, but hopefully you've got the point.
How does that translate into sh code?
What I came up with:
Here I'm using Perl's Net::IPv4Addr module.