This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ipaddress | |
def is_ip_in_cidr(ip_address, cidr_range): | |
try: | |
network = ipaddress.ip_network(cidr_range, strict=False) | |
ip = ipaddress.ip_address(ip_address) | |
return ip in network | |
except ValueError as e: | |
return f"Error: {e}" |
OlderNewer