认识
官网:https://maxmind.github.io/libmaxminddb/
文档:https://maxmind.github.io/libmaxminddb/
仓库:https://github.com/maxmind/libmaxminddb
libmaxminddb – a library for working with MaxMind DB files | The libmaxminddb library provides a C library for reading MaxMind DB files, including the GeoIP2 databases from MaxMind. This is a custom binary format designed to facilitate fast lookups of IP addresses while allowing for great flexibility in the type of data associated with an address. 简而言之,libmaxminddb 是个 MaxMind DB 的读取工具。
组成
命令程序 and 配置文件
/usr/bin/mmdblookup
/usr/share/doc/mmdb-bin/changelog.Debian.gz
/usr/share/doc/mmdb-bin/copyright
/usr/share/man/man1/mmdblookup.1.gz
构建
安装 mmdb 查询工具:
apt-cache search maxmind | grep MaxMind apt-get install mmdb-bin # Ubuntu
应用
在数据库中查询 IP 地址归属地:
# mmdblookup --file GeoLite2-Country_20210525/GeoLite2-Country.mmdb --ip 121.31.152.66 ... # mmdblookup --file GeoLite2-Country_20210525/GeoLite2-Country.mmdb --ip 121.31.152.66 country names zh-CN "中国" <utf8_string> # mmdblookup --file GeoLite2-City_20210525/GeoLite2-City.mmdb --ip 121.31.152.66 city names zh-CN "珠海市" <utf8_string>