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'
)
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"}
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
The dockerfile imports a free public Database provided by https://www.maxmind.com/en/home