SkillAgentSearch skills...

Ips

IP geolocation databases tool and library. IP 地理位置数据库工具。

Install / Use

/learn @sjzar/Ips
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

IPS

Go Report Card GoDoc GitHub release GitHub license

ips 是一个命令行工具与库,可以轻松完成 IP 地理位置数据库的查询、转存与打包。

中文 | English

下载与安装

源码安装

go install github.com/sjzar/ips@latest

二进制安装

Windows Unix MacOS

GitHub Releases 下载最新版本的二进制文件。

Homebrew 安装

brew tap sjzar/tap
brew install ips

特性

  • 一键查询、转存和打包 IP 地理位置数据库
  • 兼容多种数据库格式
  • 通过命令行参数或管道进行查询
  • 输出支持文本和 JSON 格式
  • 可自定义查询字段并持久化配置
  • 灵活的数据库字段改写:按需增减字段和内容修改

数据库支持列表

| 数据库 | 查询 | 转存 | 打包 | 官方网站 | 说明 | |:----------|:---|:---|:---|:--------------------------------------------------|:----------| | txt | ✅ | ✅ | ✅ | - | 本项目转存时使用 | | ipdb | ✅ | ✅ | ✅ | Link | | | mmdb | ✅ | ✅ | ✅ | Link | | | awdb | ✅ | ✅ | - | Link | | | qqwry | ✅ | ✅ | - | Link | IPv4 only | | czdb | ✅ | ✅ | - | Link | | | zxinc | ✅ | ✅ | - | Link | IPv6 only | | ip2region | ✅ | ✅ | - | Link | IPv4 only |

使用方法

更详细的使用说明请翻阅 usage.md

查询

# 基础查询
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

许可

ips 是在 Apache-2.0 许可下的开源软件。

致谢

View on GitHub
GitHub Stars420
CategoryData
Updated11d ago
Forks38

Languages

Go

Security Score

100/100

Audited on Mar 18, 2026

No findings