What is the total amount of public IPv4 addresses?

前端 未结 5 1762
独厮守ぢ
独厮守ぢ 2020-12-24 04:46

Yes, I am needing to know what the total number possible IPs in the public IPv4 space.

I\'m not sure where to even get a neat list of all the IP address ranges, so

5条回答
  •  难免孤独
    2020-12-24 05:27

    Public IP Addresses

    https://github.com/stephenlb/geo-ip will generate a list of Valid IP Public Addresses including Localities.

    '1.0.0.0/8' to '191.0.0.0/8' are the valid public IP Address range exclusive of the reserved Private IP Addresses as follows:

    import iptools
    ## Private IP Addresses
    private_ips = iptools.IpRangeList(
        '0.0.0.0/8',      '10.0.0.0/8',     '100.64.0.0/10', '127.0.0.0/8',
        '169.254.0.0/16', '172.16.0.0/12',  '192.0.0.0/24',  '192.0.2.0/24',
        '192.88.99.0/24', '192.168.0.0/16', '198.18.0.0/15', '198.51.100.0/24',
        '203.0.113.0/24', '224.0.0.0/4',    '240.0.0.0/4',   '255.255.255.255/32'
    )
    

    IP Generator

    Generates a JSON dump of IP Addresses and associated Geo information. Note that the valid public IP Address range is from '1.0.0.0/8' to '191.0.0.0/8' excluding the reserved Private IP Address ranges shown lower down in this readme.

    docker build -t geo-ip .
    docker run -e IPRANGE='54.0.0.0/30' geo-ip               ## a few IPs
    docker run -e IPRANGE='54.0.0.0/26' geo-ip               ## a few more IPs
    docker run -e IPRANGE='54.0.0.0/16' geo-ip               ## a lot more IPs
    docker run -e IPRANGE='0.0.0.0/0'   geo-ip               ## ALL IPs ( slooooowwwwww )
    docker run -e IPRANGE='0.0.0.0/0'   geo-ip > geo-ip.json ## ALL IPs saved to JSON File
    docker run geo-ip 
    

    A little faster option for scanning all valid public addresses:

    for i in $(seq 1 191); do \
        docker run -e IPRANGE="$i.0.0.0/8" geo-ip; \
        sleep 1; \ 
    done
    

    This prints less than 4,228,250,625 JSON lines to STDOUT. Here is an example of one of the lines:

    {"city": "Palo Alto", "ip": "0.0.0.0", "longitude": -122.1274,
     "continent": "North America", "continent_code": "NA",
     "state": "California", "country": "United States", "latitude": 37.418,
     "iso_code": "US", "state_code": "CA", "aso": "PubNub",
     "asn": "11404", "zip_code": "94107"}
    

    Private and Reserved IP Range

    The dockerfile in the repo above will exclude non-usable IP addresses following the guide from the wikipedia article: https://en.wikipedia.org/wiki/Reserved_IP_addresses

    MaxMind Geo IP

    The dockerfile imports a free public Database provided by https://www.maxmind.com/en/home

提交回复
热议问题