Created
May 30, 2022 20:23
-
-
Save jpbaudoin/7d3f0cb3ada668962f9c48f9401283d8 to your computer and use it in GitHub Desktop.
_Network
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 | |
import argparse | |
def check_ip_in_crd(ip, cidr): | |
return ipaddress.ip_address(ip) in ipaddress.ip_network(cidr) | |
parser = argparse.ArgumentParser(description='Check if IP is CIRD.') | |
parser.add_argument('IP', type=str, | |
help='IP to check') | |
parser.add_argument('CIRD', type=str, | |
help='CIRD where to check if the IP is.') | |
args = parser.parse_args() | |
IP = args.IP | |
CIRD = args.CIRD | |
print(check_ip_in_crd(IP, CIRD)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment