Skip to content

Instantly share code, notes, and snippets.

@res0nat0r
Created March 16, 2023 01:08
Show Gist options
  • Save res0nat0r/81ca619a216d5e313af32ea774e3e6c1 to your computer and use it in GitHub Desktop.
Save res0nat0r/81ca619a216d5e313af32ea774e3e6c1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from ipaddress import ip_network, ip_address
import sys
cidrs = []
with open(sys.argv[1], "r") as f:
for line in f:
cidrs.append(line.strip())
for cidr in cidrs:
net = ip_network(cidr)
print(f"ip address {sys.argv[2]} in {net}: ", end="")
print(ip_address(sys.argv[2]) in net)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment