免费、自动更新的 GeoIP 数据库集合 - 提供 MaxMind GeoLite2、DB-IP 等数据库的自动化下载和发布服务
无需注册 MaxMind 账号,无需申请 License Key,直接从 Releases 下载最新数据库!
- ✅ 完全免费 - 无需注册,无需 License Key(DB-IP 版本)
- 🤖 自动更新 - GeoLite2 每周更新(周二、周五),DB-IP 每月更新(1号、15号)
- 📦 开箱即用 - 直接下载
.mmdb文件即可使用 - 多种数据库 - 提供 City、Country、ASN 等多种数据库
- 🌐 多种来源 - 同时提供 MaxMind GeoLite2 和 DB-IP 数据库
- ✅ 质量保证 - 自动化测试确保数据库完整性
- 🚀 自托管 API - 提供开箱即用的 GeoIP 查询 API 服务和 Web 界面
本项目现在提供了基于 Golang 实现的 GeoIP 查询 API 服务,支持:
- 🌐 RESTful API - 标准的 HTTP API 接口
- 🖥️ Web 界面 - 用户友好的查询界面
- 🔄 多数据库支持 - 兼容 GeoLite2 和 DB-IP
- 🚀 轻量部署 - Docker 支持,一键启动
- 📊 实时监控 - 数据库状态和系统监控
# 1. 克隆仓库
git clone https://github.com/lwpk110/free-geoip-databases.git
cd free-geoip-databases
# 2. 下载数据库(使用 DB-IP,无需注册)
./scripts/download_dbip.sh all
# 3. 启动服务
make run
# 或使用 Docker
make docker-run访问 http://localhost:8080 即可使用 Web 界面查询 IP 地址!
详细文档请查看 GeoIP API 文档。
访问 Releases 页面 下载最新数据库文件:
| 数据库 | 说明 | 文件大小 | 授权 | 获取方式 |
|---|---|---|---|---|
| GeoLite2-City | 城市级别地理位置数据 | ~70 MB | GeoLite2 EULA | Releases 页面 |
| GeoLite2-Country | 国家级别地理位置数据 | ~6 MB | GeoLite2 EULA | Releases 页面 |
| GeoLite2-ASN | ASN 网络运营商数据 | ~8 MB | GeoLite2 EULA | Releases 页面 |
注意: GeoLite2 数据库文件名包含日期信息(如
GeoLite2-City-20251105.mmdb),请访问 Releases 页面选择最新版本下载。
查看 DB-IP Releases 下载 DB-IP 数据库:
| 数据库 | 说明 | 文件大小 | 授权 | 获取方式 |
|---|---|---|---|---|
| DB-IP City Lite | 城市级别地理位置数据 | ~130 MB | CC BY 4.0 | Releases 页面 |
| DB-IP Country Lite | 国家级别地理位置数据 | ~7 MB | CC BY 4.0 | Releases 页面 |
| DB-IP ASN Lite | ASN 网络运营商数据 | ~9 MB | CC BY 4.0 | Releases 页面 |
注意: DB-IP 数据库文件名包含年月信息(如
dbip-city-lite-2025-11.mmdb),请访问 Releases 页面选择最新版本下载。
由于文件名包含日期信息,建议通过以下方式获取最新数据库:
方法一:使用项目提供的下载脚本
# MaxMind GeoLite2(需要 License Key)
./scripts/download_geolite2.sh <YOUR_LICENSE_KEY>
# DB-IP(无需 License Key)
./scripts/download_dbip.sh all方法二:从 GitHub Releases 下载
# 访问 Releases 页面选择最新版本
# GeoLite2: https://github.com/lwpk110/free-geoip-databases/releases?q=geolite2
# DB-IP: https://github.com/lwpk110/free-geoip-databases/releases?q=dbip
# 或使用 GitHub CLI
gh release list --repo lwpk110/free-geoip-databases
gh release download <tag-name> --repo lwpk110/free-geoip-databasespackage main
import (
"fmt"
"log"
"net"
"github.com/oschwald/geoip2-golang"
)
func main() {
// 打开数据库
db, err := geoip2.Open("GeoLite2-City.mmdb")
if err != nil {
log.Fatal(err)
}
defer db.Close()
// 查询 IP
ip := net.ParseIP("8.8.8.8")
record, err := db.City(ip)
if err != nil {
log.Fatal(err)
}
// 输出结果
fmt.Printf("国家: %s\n", record.Country.Names["zh-CN"])
fmt.Printf("城市: %s\n", record.City.Names["zh-CN"])
fmt.Printf("经纬度: %.4f, %.4f\n", record.Location.Latitude, record.Location.Longitude)
}import geoip2.database
# 打开数据库
with geoip2.database.Reader('GeoLite2-City.mmdb') as reader:
# 查询 IP
response = reader.city('8.8.8.8')
# 输出结果
print(f"国家: {response.country.names['zh-CN']}")
print(f"城市: {response.city.names.get('zh-CN', 'N/A')}")
print(f"经纬度: {response.location.latitude}, {response.location.longitude}")const maxmind = require('maxmind');
// 打开数据库
maxmind.open('GeoLite2-City.mmdb').then(lookup => {
// 查询 IP
const result = lookup.get('8.8.8.8');
// 输出结果
console.log(`国家: ${result.country.names['zh-CN']}`);
console.log(`城市: ${result.city.names['zh-CN']}`);
console.log(`经纬度: ${result.location.latitude}, ${result.location.longitude}`);
});- 自动更新: 每周二和周五(UTC 10:00 / 北京时间 18:00)
- 数据源: MaxMind 官方 GeoLite2 数据库
- 更新策略: 跟随 MaxMind 官方更新周期
- 自动更新: 每月1号和15号(UTC 10:00 / 北京时间 18:00)
- 数据源: DB-IP 官方免费数据库
- 更新策略: 下载当月最新版本
- 授权: Creative Commons Attribution 4.0 (CC BY 4.0)
| 特性 | GeoLite2 | DB-IP Lite |
|---|---|---|
| 授权 | 需遵守 MaxMind EULA | CC BY 4.0(更自由) |
| 更新频率 | 每周2次 | 每月1次 |
| 数据准确性 | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| 文件格式 | .mmdb | .mmdb(兼容) |
| 使用限制 | 非商业用途优先 | 署名即可商用 |
| 注册要求 | 需要(本项目已处理) | 无需注册 |
| 数据库类型 | 包含信息 | 文件大小 |
|---|---|---|
| City | 国家、省份/州、城市、邮编、经纬度、时区 | ~70 MB |
| Country | 国家、大洲 | ~6 MB |
| ASN | 自治系统号、网络运营商 | ~8 MB |
本项目提供了简单的 Go 语言查询工具,可以测试数据库文件。
free-geoip-databases/
├── .github/workflows/ # GitHub Actions 自动化工作流
│ ├── update-geolite2.yml
│ ├── update-dbip.yml
│ └── test-database.yml
├── scripts/ # 下载脚本
│ ├── download_geolite2.sh
│ └── download_dbip.sh
├── examples/ # 示例代码
│ ├── query/ # IP 查询示例
│ │ └── main.go
│ └── test/ # 测试程序
│ └── test_cities.go
├── docs/ # 详细文档
│ ├── QUICKSTART.md
│ └── TESTING.md
├── README.md
├── LICENSE
├── go.mod
└── go.sum
# 1. 克隆仓库
git clone https://github.com/lwpk110/free-geoip-databases.git
cd free-geoip-databases
# 2. 下载数据库文件
./scripts/download_geolite2.sh <YOUR_LICENSE_KEY>
# 或使用 DB-IP (无需 License Key)
./scripts/download_dbip.sh all
# 3. 安装依赖
go mod tidy
# 4. 运行查询示例
cd examples/query
go run main.go
# 5. 运行测试
cd ../test
go run test_cities.go更多详情请查看 examples/README.md 和 docs/cn/TESTING.md。
如果你想 Fork 本项目并实现自己的 GeoLite2 自动更新:
-
Fork 本仓库
-
添加 MaxMind License Key
- 访问 MaxMind 注册
- 生成 License Key
- 在你的仓库中:Settings → Secrets and variables → Actions
- 添加 Secret:
MAXMIND_LICENSE_KEY
-
添加 GitHub Token
- 在你的仓库中:Settings → Secrets and variables → Actions
- 添加 Secret:
GEOIP_ACCESS_TOKEN(使用有 repo 权限的 Personal Access Token)
-
启用 GitHub Actions
- 工作流将自动运行
- 或手动触发:Actions → Update GeoLite2 Database → Run workflow
DB-IP 数据库无需任何配置,只需:
-
Fork 本仓库
-
添加 GitHub Token
- 在你的仓库中:Settings → Secrets and variables → Actions
- 添加 Secret:
GEOIP_ACCESS_TOKEN
-
启用 GitHub Actions
- DB-IP 工作流会自动运行
- 或手动触发:Actions → Update DB-IP Database → Run workflow
提示: DB-IP 不需要注册账号或 License Key,完全免费且开放!
- 项目代码: MIT License
- GeoLite2 数据库: 由 MaxMind 提供,需遵守 MaxMind EULA
- This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com
- DB-IP 数据库: 由 DB-IP 提供,使用 Creative Commons Attribution 4.0 授权
- 使用时需要署名:Contains data from https://db-ip.com
- GeoLite2 和 DB-IP Lite 都是免费版本,精确度低于商业版
- GeoLite2: 仅供学习、测试和非商业用途,商业用途请购买 MaxMind 商业授权
- DB-IP: 可商用,但需要署名(Attribution required)
- 如需更高精确度或商业支持,请考虑购买商业版数据库
如果这个项目对你有帮助,请给一个 ⭐ Star!这将激励我持续维护和更新。
欢迎提交 Issue 和 Pull Request!