10.2.186.8
10.2.186.64
10.2.186.65
172.7.143.6
172.7.143.33
172.7.143.34
172.7.143.35
и т.д.
10.2.186.8
10.2.186.64/31
172.7.143.6
172.7.143.33/30
perl -MNet::CIDR::Lite -le 'print join"\n",Net::CIDR::Lite->new(@ARGV)->list' 10.2.186.8 10.2.186.64 10.2.186.65 172.7.143.6 172.7.143.33 172.7.143.34 172.7.143.35
10.2.186.8/32
10.2.186.64/31
172.7.143.6/32
172.7.143.33/32
172.7.143.34/31
>>>> import ipaddress
>>> list_of_ips = ['10.0.0.0', '10.0.0.1', '10.0.0.2', '10.0.0.3', '10.0.0.5']
>>> nets = [ipaddress.ip_network(_ip) for _ip in list_of_ips]
>>> cidrs = ipaddress.collapse_addresses(nets)
>>> print(list(cidrs))
[IPv4Network('10.0.0.0/30'), IPv4Network('10.0.0.5/32')]