This commit is contained in:
Be
2024-03-03 23:40:11 +01:00
parent 7bbb894dab
commit 64ee04be20
4 changed files with 109 additions and 9 deletions

8
pylib/ip.py Executable file
View File

@@ -0,0 +1,8 @@
import ipaddress
def convert_to_cidr(ip_range):
start_ip, end_ip = ip_range.split(' - ')
start_ip = ipaddress.IPv4Address(start_ip)
end_ip = ipaddress.IPv4Address(end_ip)
cidrs = ipaddress.summarize_address_range(start_ip, end_ip)
return [str(cidr) for cidr in cidrs]