A lightweight, production-ready GeoIP database optimized for quick IP lookups. This project automatically merges multiple open-source GeoIP data sources and outputs a single MMDB file containing country codes, ASN, and organization information.
Weekly automated builds with the latest GeoIP data.
Fork of daijro/geoip-all-in-one - optimized for Country+ASN+ORG only (lite profile)
- 🚀 Lightweight: ~18MB for global IPv4 + IPv6 coverage
- 🌐 Country Codes: ISO 3166-1 alpha-2 format
- 🔢 ASN Data: ~95% coverage for IPv4, ~90% for IPv6
- 🏢 Organization Names: Mappings from ASN to organization
- 📈 Multi-source Voting: Combines 9 country signals (global + CN route feeds)
- 🔄 Automated Updates: Weekly releases via GitHub Actions
Get the latest Country.mmdb from Releases.
import maxminddb
with maxminddb.open_database('Country.mmdb') as reader:
data = reader.get('99.109.2.2')
print(data)
# Output:
# {
# 'country': {'iso_code': 'US'},
# 'autonomous_system_number': 7018,
# 'autonomous_system_organization': 'ATT-INTERNET4'
# }Used to determine the authoritative country for each IP range:
-
IP2Location LITE - Commercial geolocation database
- Coverage: Global
- Update frequency: Monthly
- Source: https://lite.ip2location.com
-
Geo-WHOIS-ASN-Country - Official RIR WHOIS data
- Coverage: High accuracy, lower coverage
- Update frequency: Weekly
- Source: Regional Internet Registries (AFRINIC, APNIC, ARIN, LACNIC, RIPE NCC)
-
DB-IP LITE - Dedicated geolocation database
- Coverage: Global
- Update frequency: Monthly
- Source: https://db-ip.com
-
GeoLite2 - MaxMind free geolocation database
- Coverage: Comprehensive
- Update frequency: Monthly
- Source: https://www.maxmind.com
-
IPinfo Country - IPinfo.io geolocation data
- Coverage: Global
- Update frequency: Weekly
- Source: https://ipinfo.io
-
IPlocate - IPlocate geolocation data
- Coverage: Global
- Update frequency: Monthly
- Source: https://iplocate.io
-
CN Clang Route Feed - China route list (IPv4 + IPv6)
- Coverage: CN-focused
- Source: https://ispip.clang.cn
-
17mon China IP List - China route list (IPv4)
- Coverage: CN-focused
- Source: https://github.com/17mon/china_ip_list
-
chnroutes2 - China route list (IPv4)
- Coverage: CN-focused
- Source: https://github.com/misakaio/chnroutes2
Note: 17mon and chnroutes2 currently provide IPv4 route ranges only in this build.
IPtoASN - Authoritative ASN-to-organization mapping
- Format: TSV with start/end IPs, ASN, country, organization
- Coverage: ~95% IPv4, ~90% IPv6
- Update frequency: Daily
- Source: https://iptoasn.com
# Python 3.11+
# Create virtual environment (recommended)
python3 -m venv .venv
source .venv/bin/activate# Install dependencies
make deps
# Download all data sources
make download
# Merge data with voting algorithm
make merge
# Build MMDB
make buildCountry.mmdb- Final database file (~18MB)merged_ipv4.tsv- Intermediate merged datamerged_ipv6.tsv- Intermediate merged data
The merge process uses a multi-stage voting algorithm:
-
Country Voting (9 sources)
- Each IP range receives votes from 9 country signals
- Highest vote count wins
- Tie-breaking: Uses configured priority order
-
ASN/Organization Extraction
- Primary source: IPtoASN.com
- Fallback: WHOIS data (if available from voting results)
- Normalization: Handles missing values, invalid entries
-
Range Merging (Lite Profile)
- Adjacent IP ranges with identical (country, ASN, ORG) are merged
- Reduces database size by ~73% (8.07M → 1.09M ranges)
- No precision loss for retained fields
{
"country": {
"iso_code": "US" // 2-letter ISO 3166-1 alpha-2
},
"autonomous_system_number": 7018, // 32-bit integer
"autonomous_system_organization": "ATT-INTERNET4" // String
}- Type: MaxMind MMDB v2.0
- Database Type: GeoIP2-Country-ASN
- IP Version: 6 (includes IPv4-compatible)
- Total Ranges: ~1.09M (IPv4 + IPv6 combined)
Automated builds run on:
- Schedule: Weekly (Wednesday 03:00 UTC)
- Push: On every commit to
mainbranch - Manual: Available via
workflow_dispatch
Releases are automatically created with:
- Release notes
- Database file
- Metadata (size, build time)
Older releases (> 3) are automatically cleaned up.
| Aspect | City MMDB | Country MMDB (Lite) |
|---|---|---|
| Size | 106 MB | 18 MB |
| IPv4 Ranges | 8.07M | 635K |
| IPv6 Ranges | 3.94M | 454K |
| Country | ✓ | ✓ |
| Coordinates | ✓ | ✗ |
| Timezone | ✓ | ✗ |
| ASN | ✓ | ✓ |
| Organization | ✓ | ✓ |
| Use Case | Full geolocation | IP origin/routing |
| Source | License | Attribution |
|---|---|---|
| IP2Location LITE | CC BY 4.0 | IP2Location |
| GeoLite2 | CC BY 4.0 | MaxMind |
| DB-IP Lite | CC BY 4.0 | DB-IP |
| IPtoASN | CC BY 4.0 | IPtoASN |
| RIR WHOIS | Public | RIRs |
This project is open source. All contributions welcome.
- 📦 Latest Release
- 📋 License
- 🐛 Issues
- 📝 Changelog