[MASOCH-L] agrupar em CIDRs

Anderson C. Santos anderson at microquest.com.br
Mon Apr 9 16:46:12 -03 2018


Prezado Leonardo,

  Talvez ajude:

=========================
#!/usr/bin/env python

from netaddr import iprange_to_cidrs

def get_cidr(first_ip, last_ip):
    return [str(cidr)
            for cidr in iprange_to_cidrs(first_ip, last_ip)]

print get_cidr('192.168.0.1', '192.168.1.15');
==========================

  Adaptado de:

  https://stackoverflow.com/questions/24214441/ip-range-to-cidr-conversion-in-python
  https://www.ip2location.com/tutorials/how-to-convert-ip-address-range-into-cidr
  https://ip2cidr.com/bulk-ip-to-cidr-converter.php
  http://tech.marksblogg.com/bulk-ip-address-whois-python-hadoop.html
  https://softwareengineering.stackexchange.com/questions/246460/reduce-a-list-of-ipv4-to-lowest-common-cidr

  Abracos,

  Anderson C. Santos
  anderson at microquest.com.br

On 09/04/2018 16:17, Leonardo Rodrigues wrote:

>
>     Olá pessoal,
>
>     Alguém sabe me indicar um script ou página que, fornecida uma
> lista de IPs, consiga agrupar IPs na mesma faixa em algum respectivo
> CIDR ?
>
>     Obrigado.
>



More information about the masoch-l mailing list