「GeoLite」- GeoLite | MaxMind | free GeoIP data

认识

官网:https://www.maxmind.com/en/geolite-free-ip-geolocation-data
文档:https://dev.maxmind.com/geoip/docs/databases/

Since 2002, MaxMind has offered GeoLite, a free version of our IP geolocation databases. 简而言之,GeoLite 是 MaxMind 提供的免费的地址数据库(简版 GeoIP 数据),是我们能够使用这个数据库文件进行查询。针对很多开源软件,例如,Nginx ELasticsearch、……,其都在使用 MaxMind 提供的 GeoLite 数据库。

GeoLite was initially released under the Creative Commons license to the open source community as a way for independent developers to experiment and create with IP geolocation data.

MaxMind continues to incorporate Creative Commons into our GeoLite End User Agreement (EULA), which has been updated to keep pace with modern privacy regulations and best practices.

构建

通过官网下载

⚠️,注意事项,Downloads of this database from CN are forbidden due to US bulk sensitive data transfer rules,我们并不清楚其具体检测方法,所以我们在注册账号时:

  • 使用 Gmail 进行注册,
  • 注册信息填写国外地址,需要修改账号地域,
  • 并且使用非大陆及港澳台的代理节点来下载。

当登陆时,其会要求输入邮箱验证码,该邮件内容的 Estimated Location 部分仅包含国内或港澳台地址,那么大概率是无法下载的。

第一步、注册 MaxMind 帐号,否则无法下载数据库文件(以往无需注册)。

第二步、访问 Download Files 页面,以下载数据库文件。

# 下载 GeoLite2 City .mmdb 文件(手动下载)
# 下载 GeoLite2 Country .mmdb 文件(手动下载)

# 解压数据库文件
tar -xf GeoLite2-City_20210525.tar.gz
tar -xf GeoLite2-Country_20210525.tar.gz

数据库文件的自动更新,参考 Updating GeoIP and GeoLite Databases 文档。

通过镜像获取

例如,https://hub.docker.com/r/observabilitystack/geoip-api

我们受制于地域及政策,配置使用相关容器镜像较为繁琐,所以该处仅作记录。

通过仓库获取

https://github.com/Dreamacro/maxmind-geoip

参考

国内哪个精确到城市的 IP 地址库最精确完善?
IpAreaRoute/ 根据 apnic 数据文件制作的海外网段信息
NGINX Docs | Restricting Access by Geographical Location