GitHub - sjzar/ips: IP geolocation databases tool and library. IP 地理位置数据库工具。
2023-12-2 03:31:35 Author: github.com(查看原文) 阅读量:15 收藏

# 基础查询
ips <ip或文本> [选项]

# 查询 IP
ips 61.144.235.160
# 输出:61.144.235.160 [中国 广东 深圳 电信]

# 使用管道查询 IP
echo "61.144.235.160" | ips
# 输出:61.144.235.160 [中国 广东 深圳 电信]

# 使用指定的数据库文件查询 IP
ips -d ./GeoLite2-City.mmdb 61.144.235.160
# 输出:61.144.235.160 [中国 广州]

# 使用指定的数据库文件并设置查询字段
ips -d ./GeoLite2-City.mmdb --fields country 61.144.235.160
# 输出:61.144.235.160 [中国]

# 使用指定的数据库文件,以 JSON 格式输出结果
ips -d ./GeoLite2-City.mmdb --fields '*' -j 61.144.235.160
# 输出:{"ip":"61.144.235.160","net":"61.144.192.0/18","data":{"city":"广州市","continent":"亚洲","country":"中国","latitude":"23.1181","longitude":"113.2539","utcOffset":"Asia/Shanghai"}}
# 基础转存命令,输出转存内容
ips dump -i ./qqwry.dat
# 输出:
#    # Dump Time: 2023-10-20 00:00:00
#    # Fields: country,area
#    ... <省略部分输出> ...

# 指定字段进行转存
ips dump -i ./qqwry.dat -f country
# 输出:
#    # Dump Time: 2023-10-20 00:00:00
#    # Fields: country
#    ... <省略部分输出> ...

# 转存内容并保存到文件
ips dump -i ./qqwry.dat -o 1.txt
# 使用转存文件进行打包
ips pack -i qqwry.txt -o qqwry.ipdb

# 使用数据库文件进行打包
ips pack -i qqwry.dat -o qqwry.ipdb

# 使用数据库文件并指定字段进行打包
ips pack -i qqwry.dat -f country -o country.ipdb

文章来源: https://github.com/sjzar/ips
如有侵权请联系:admin#unsafe.sh