$ echo 108.162.192.{1..5}| python3 -c 'import sys;import requests;import ipaddress as i;ranges=requests.get("https://www.cloudflare.com/ips-v4").text.split();ips=sys.stdin.read().split(); [[print(ip) for rng in ranges if i.IPv4Address(ip) in i.IPv4Network(rng)] for ip in ips]'
108.162.192.1
108.162.192.2
108.162.192.3
108.162.192.4
108.162.192.5

The idea is, that you have some IP addresses, you grep’ed out of logs or something and you just need to confirm, if one of them are a Cloudflare IP. You pipe it into the above python oneliner. If it exists in the list of CIDR ranges returned, then prints it out, as confrimation.

This same techinic can be used in order to confirm if an IP address exists in any CIDR range. Check, out the quick edit, I did to the oneliner.

$ echo 8.8.8.8|python3 -c 'import sys;import requests;import ipaddress as i;ranges="142.250.0.0/15 8.8.8.0/24".split();ips=sys.stdin.read().split(); [[print(ip) for rng in ranges if i.IPv4Address(ip) in i.IPv4Network(rng)] for ip in ips]'
8.8.8.8