ip - Python Lowest Common CIDR -
say have 2 ips: startip = '63.223.64.0'
, endip = '63.223.127.255'
i understand in python netaddr.iprange_to_cidrs(startip, endip)
give list of cidr subnets fit between boundaries. however, hoping go one cidr subnet covers if gives few more ips.
i prefer function it, welcome math/logic calculate , turn code.
it looks netaddr.spanning_cidr
trick:
in [5]: netaddr.spanning_cidr(['63.223.64.0', '63.223.127.255']) out[5]: ipnetwork('63.223.64.0/18')
Comments
Post a Comment