Generate the latest country IP ranges in CIDR notation
The shell script generate.sh
will download the latest RIR statistics files (RIR statistics exchange format) from the following five Regional Internet Registries (RIRs).
URLs:
https://ftp.apnic.net/stats/apnic/delegated-apnic-latest
https://ftp.arin.net/pub/stats/arin/delegated-arin-extended-latest
https://ftp.ripe.net/ripe/stats/delegated-ripencc-latest
https://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest
https://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest
It then grabs entries from the files above. Generate country_code.txt
. Convert IP ranges to CIDR notation. Generate IP files for each country.
Generate Japan IPv4 ranges from APNIC and save them to JP_IPv4.txt
.
curl -sL https://ftp.apnic.net/stats/apnic/delegated-apnic-latest | \
grep "apnic|JP|ipv4" | \
awk -F '|' '{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' | \
tee JP_IPv4.txt
This will generate all countries and save IP files to your current directory.
curl -sL https://github.com/HackingGate/Country-IP-Blocks/raw/master/generate.sh | sh
The country code is under ISO 3166-2 standard.
The following files are hosted on GitHub Pages.
- Mirror files of
delegated-*-latest
country_code.txt
- Country IP Block files
Available at https://hackinggate.github.io/Country-IP-Blocks/
and auto-updates by GitHub Workflows.
Since this project uses git.
You can view IP changes from gh-pages branch.
Such as comparing files between git commits to see when and what entries are added or deleted.