This repository includes automated daily exports of the complete RIR database via GitHub Actions.
What it does:
- Downloads the latest RIR database dumps from all regional registries (ARIN, RIPE, APNIC, LACNIC, AfriNIC)
- Parses the data into a PostgreSQL database
- Exports the complete database to a gzipped CSV file
- Creates a GitHub Release with the exported file
Schedule: Runs daily at 00:00 UTC (can also be triggered manually)
Download latest exports: https://github.com/bralbral/network_info/releases
File format: Gzipped CSV containing all network blocks with fields:
- inetnum (CIDR notation)
- netname
- country
- description
- maintained_by
- created
- last_modified
- source (RIR)
- status
To deploy the application using Docker Compose:
./bin/network_infoThis command will:
- Build the Docker image
- Start the PostgreSQL database container
- Download the latest RIR database dumps
- Parse the data into the database
The database container remains running after the initial import. You can verify it with:
docker psTo query a specific IP address:
./bin/query 8.8.8.8For direct SQL access to the database:
./bin/psqlExample queries you can run in the psql shell:
-- Find network information for an IPv4 address
SELECT inetnum, netname, country, description, maintained_by, source
FROM block
WHERE inetnum >> '8.8.8.8'
ORDER BY inetnum DESC;
-- Find all networks for a specific country
SELECT inetnum, netname, description
FROM block
WHERE country = 'US'
LIMIT 10;
-- Search by netname
SELECT inetnum, country, description
FROM block
WHERE netname ILIKE '%google%'
LIMIT 10;If you need to export data from PG to another source (Clickhouse, Elasticsearch, etc.) you can use:
./bin/export_to_gzip
A compressed CSV file will be created with the current date in the filename.
The script supports various options:
./bin/export_to_gzip [OPTIONS]
Options:
-d, --delimiter DELIMITER Field delimiter (default: ',')
-t, --table TABLE Table name to export (default: block)
-o, --output PREFIX Output file prefix (default: block_dump)
-h, --host HOST Database host (default: db)
-u, --user USER Database user (default: network_info)
-n, --database NAME Database name (default: network_info)
-p, --password PASSWORD Database password (default: network_info)
--help Show this help message
Examples:
# Default export (comma delimiter)
./bin/export_to_gzip
# Export with semicolon delimiter
./bin/export_to_gzip -d ';'
# Export as TSV (tab-separated)
./bin/export_to_gzip -d $'\t'
# Export custom table with pipe delimiter
./bin/export_to_gzip -t users -d '|' -o users_dump
You can also export the database to MaxMind DB (MMDB) format for use with GeoIP2-compatible tools:
docker compose run --rm network_info export_to_mmdb.pyThis will create a file named block_dump_YYYY-MM-DD.mmdb with the current date.
For custom output filename or table:
docker compose run --rm network_info export_to_mmdb.py -o custom_output.mmdb -t blockThe MMDB file contains the following network information fields for each IP range:
- netname - Network name identifier
- country - Country code (e.g., US, RU, DE)
- description - Network description
- maintained_by - Maintainer information
- created - Creation date (YYYY-MM-DD format)
- last_modified - Last modification date (YYYY-MM-DD format)
- source - Source RIR (ARIN, RIPE, APNIC, LACNIC, AfriNIC)
- status - Network status
Once you have the MMDB file, you can use it with various tools:
Simple lookup:
import maxminddb
# Open the MMDB file
with maxminddb.open_database('block_dump_2026-05-01.mmdb') as reader:
# Lookup an IP address
result = reader.get('8.8.8.8')
if result:
print(f"Network: {result['netname']}")
print(f"Country: {result['country']}")
print(f"Source: {result['source']}")# Install mmdblookup tool
sudo apt install mmdb-bin
# Lookup an IP address
mmdblookup --file block_dump_2026-05-01.mmdb --ip 8.8.8.8