{"id":13459335,"url":"https://github.com/zu1k/nali","last_synced_at":"2025-04-23T20:48:59.317Z","repository":{"id":37363152,"uuid":"280292779","full_name":"zu1k/nali","owner":"zu1k","description":"An offline tool for querying IP geographic information and CDN provider. 一个查询IP地理信息和CDN服务提供商的离线终端工具.","archived":false,"fork":false,"pushed_at":"2025-02-21T06:13:25.000Z","size":37441,"stargazers_count":3935,"open_issues_count":15,"forks_count":356,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-04-18T17:24:54.947Z","etag":null,"topics":["cdn","cdn-provider","chunzhen","cli","geoip","geoip2","golang","ip","ipip","nali","nali-cli","qqwry","qqwry-ip-database","zx-ipv6"],"latest_commit_sha":null,"homepage":"https://github.com/zu1k/nali","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zu1k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"zu1k","custom":["https://zu1k.com/donate/"]}},"created_at":"2020-07-17T01:02:26.000Z","updated_at":"2025-04-18T06:20:06.000Z","dependencies_parsed_at":"2023-11-24T09:28:25.940Z","dependency_job_id":"c1e20950-9a3f-412a-8436-932c5b38fada","html_url":"https://github.com/zu1k/nali","commit_stats":{"total_commits":253,"total_committers":22,"mean_commits":11.5,"dds":0.5968379446640316,"last_synced_commit":"2e758d311739bc402ba63bda7ba081d565c0cf0f"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zu1k%2Fnali","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zu1k%2Fnali/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zu1k%2Fnali/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zu1k%2Fnali/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zu1k","download_url":"https://codeload.github.com/zu1k/nali/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250513725,"owners_count":21443204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdn","cdn-provider","chunzhen","cli","geoip","geoip2","golang","ip","ipip","nali","nali-cli","qqwry","qqwry-ip-database","zx-ipv6"],"created_at":"2024-07-31T09:01:16.379Z","updated_at":"2025-04-23T20:48:59.287Z","avatar_url":"https://github.com/zu1k.png","language":"Go","funding_links":["https://patreon.com/zu1k","https://zu1k.com/donate/"],"categories":["Go","IP Info","\u003ca name=\"infra\"\u003e\u003c/a\u003einfra","网络服务","Go (531)"],"sub_categories":["Snippets Manager","网络服务_其他"],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003eNali\u003cbr\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003e一个查询IP地理信息和CDN提供商的离线终端工具.\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/zu1k/nali/actions\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/zu1k/nali/go.yml?branch=master\u0026style=flat-square\" alt=\"Github Actions\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/zu1k/nali\"\u003e\n    \u003cimg src=\"https://goreportcard.com/badge/github.com/zu1k/nali?style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/zu1k/nali/releases\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/release/zu1k/nali/all.svg?style=flat-square\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/zu1k/nali/releases\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/downloads/zu1k/nali/total?style=flat-square\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n#### [English](https://github.com/zu1k/nali/blob/master/README_en.md)\n\n## 功能\n\n- 支持多种数据库\n  - 纯真 IPv4 离线数据库\n  - ZX IPv6 离线数据库\n  - Geoip2 城市数据库 (可选)\n  - IPIP 数据库 (可选)\n  - ip2region 数据库 (可选)\n  - DB-IP 数据库 (可选)\n  - IP2Location DB3 LITE 数据库 (可选)\n- CDN 服务提供商查询\n- 支持管道处理\n- 支持交互式查询\n- 同时支持IPv4和IPv6\n- 支持多语言\n- 查询完全离线\n- 全平台支持\n- 支持彩色输出\n\n## 安装\n\n### 从源码安装\n\nNali 需要预先安装 Go \u003e= 1.19. 安装后可以从源码安装软件:\n\n```sh\n$ go install github.com/zu1k/nali@latest\n```\n\n### 下载预编译的可执行程序\n\n可以从Release页面下载预编译好的可执行程序: [Release](https://github.com/zu1k/nali/releases)\n\n你需要选择适合你系统和硬件架构的版本下载，解压后可直接运行\n\n### Arch 系 Linux\n\n我们在 Aur 中发布了 3 个相关的包:\n\n- `nali-go`: Release 版本，安装时编译\n- `nali-go-bin`: Release 版本，预编译的二进制文件\n- `nali-go-git`: 最新的 master 分支版本，安装时编译\n  \n## 使用说明\n\n### 查询一个IP的地理信息\n\n```\n$ nali 1.2.3.4\n1.2.3.4 [澳大利亚 APNIC Debogon-prefix网络]\n```\n\n#### 或者 使用 `管道`\n\n```\n$ echo IP 6.6.6.6 | nali\nIP 6.6.6.6 [美国 亚利桑那州华楚卡堡市美国国防部网络中心]\n```\n\n### 同时查询多个IP的地理信息\n\n```\n$ nali 1.2.3.4 4.3.2.1 123.23.3.0\n1.2.3.4 [澳大利亚 APNIC Debogon-prefix网络]\n4.3.2.1 [美国 新泽西州纽瓦克市Level3Communications]\n123.23.3.0 [越南 越南邮电集团公司]\n```\n\n### 交互式查询\n\n使用 `exit` 或  `quit` 退出查询\n\n```\n$ nali\n123.23.23.23\n123.23.23.23 [越南 越南邮电集团公司]\n1.0.0.1\n1.0.0.1 [美国 APNIC\u0026CloudFlare公共DNS服务器]\n8.8.8.8\n8.8.8.8 [美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器]\nquit\n```\n\n### 与 `dig` 命令配合使用\n\n需要你系统中已经安装好 dig 程序\n\n```\n$ dig nali.zu1k.com +short | nali\n104.28.2.115 [美国 CloudFlare公司CDN节点]\n104.28.3.115 [美国 CloudFlare公司CDN节点]\n172.67.135.48 [美国 CloudFlare节点]\n```\n\n### 与 `nslookup` 命令配合使用\n\n需要你系统中已经安装好 nslookup 程序\n\n```\n$ nslookup nali.zu1k.com 8.8.8.8 | nali\nServer:         8.8.8.8 [美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器]\nAddress:        8.8.8.8 [美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器]#53\n\nNon-authoritative answer:\nName:   nali.zu1k.com\nAddress: 104.28.3.115 [美国 CloudFlare公司CDN节点]\nName:   nali.zu1k.com\nAddress: 104.28.2.115 [美国 CloudFlare公司CDN节点]\nName:   nali.zu1k.com\nAddress: 172.67.135.48 [美国 CloudFlare节点]\n```\n\n### 与任意程序配合使用\n\n因为 nali 支持管道处理，所以可以和任意程序配合使用\n\n```\nbash abc.sh | nali\n```\n\nNali 将在 IP后面插入IP地理信息，CDN域名后面插入CDN服务提供商信息\n\n### 支持IPv6\n\n和 IPv4 用法完全相同\n\n```\n$ nslookup google.com | nali\nServer:         127.0.0.53 [局域网 IP]\nAddress:        127.0.0.53 [局域网 IP]#53\n\nNon-authoritative answer:\nName:   google.com\nAddress: 216.58.211.110 [美国 Google全球边缘网络]\nName:   google.com\nAddress: 2a00:1450:400e:809::200e [荷兰Amsterdam Google Inc. 服务器网段]\n```\n\n### 查询 CDN 服务提供商\n\n因为 CDN 服务通常使用 CNAME 的域名解析方式，所以推荐与 `nslookup` 或者 `dig` 配合使用，在已经知道 CNAME 后可单独使用\n\n```\n$ nslookup www.gov.cn | nali\nServer:         127.0.0.53 [局域网 IP]\nAddress:        127.0.0.53 [局域网 IP]#53\n\nNon-authoritative answer:\nwww.gov.cn      canonical name = www.gov.cn.bsgslb.cn [白山云 CDN].\nwww.gov.cn.bsgslb.cn [白山云 CDN]       canonical name = zgovweb.v.bsgslb.cn [白山云 CDN].\nName:   zgovweb.v.bsgslb.cn [白山云 CDN]\nAddress: 103.104.170.25 [新加坡 ]\nName:   zgovweb.v.bsgslb.cn [白山云 CDN]\nAddress: 2001:428:6402:21b::5 [美国Louisiana州Monroe Qwest Communications Company, LLC (CenturyLink)]\nName:   zgovweb.v.bsgslb.cn [白山云 CDN]\nAddress: 2001:428:6402:21b::6 [美国Louisiana州Monroe Qwest Communications Company, LLC (CenturyLink)]\n```\n\n## 用户交互\n\n程序第一次运行后，会在 config 目录生成配置文件 `config.yaml` (使用 `nali info` 来查看具体信息)，配置文件定义了数据库信息，默认用户无需进行修改\n\n数据库格式默认如下：\n\n```yaml\n- name: geoip\n  name-alias:\n  - geolite\n  - geolite2\n  format: mmdb\n  file: GeoLite2-City.mmdb\n  languages:\n  - ALL\n  types:\n  - IPv4\n  - IPv6\n```\n\n其中，`languages` 和 `types` 表示该数据库支持的语言和查询类型。 如果你需要增加数据库，需小心修改配置文件，如果有任何问题，欢迎提 issue 询问。\n\n### 查看帮助\n\n```\n$ nali --help\nUsage:\n  nali [flags]\n  nali [command]\n\nAvailable Commands:\n  help        Help about any command\n  update      update qqwry, zxipv6wry, ip2region ip database and cdn\n\nFlags:\n  -h, --help     help for nali\n  -t, --toggle   Help message for toggle\n\nUse \"nali [command] --help\" for more information about a command.\n```\n\n### 更新数据库\n\n更新所有可以自动更新的数据库\n\n```\n$ nali update\n2020/07/17 12:53:46 正在下载最新纯真 IP 库...\n2020/07/17 12:54:05 已将最新的纯真 IP 库保存到本地 /root/.nali/qqwry.dat\n```\n\n或者指定数据库\n\n```\n$ nali update --db qqwry,cdn\n2020/07/17 12:53:46 正在下载最新纯真 IP 库...\n2020/07/17 12:54:05 已将最新的纯真 IP 库保存到本地 /root/.nali/qqwry.dat\n```\n\n### 自选数据库\n\n用户可以指定使用哪个数据库，需要设置环境变量： `NALI_DB_IP4`、`NALI_DB_IP6` 或者两个同时设置\n\n支持的变量内容:\n\n- Geoip2 `['geoip', 'geoip2']`\n- Chunzhen `['chunzhen', 'qqwry']`\n- IPIP `['ipip']`\n- Ip2Region `['ip2region', 'i2r']`\n- DBIP `['dbip', 'db-ip']`\n- IP2Location `['ip2location']`\n\n#### Windows平台\n\n##### 使用geoip数据库\n\n```\nset NALI_DB_IP4=geoip\n\n或者使用 powershell\n\n$env:NALI_DB_IP4=\"geoip\"\n```\n\n##### 使用ipip数据库\n\n```\nset NALI_DB_IP6=ipip\n\n或者使用 powershell\n\n$env:NALI_DB_IP6=\"ipip\"\n```\n\n#### Linux平台\n\n##### 使用geoip数据库\n\n```\nexport NALI_DB_IP4=geoip\n```\n\n##### 使用ipip数据库\n\n```\nexport NALI_DB_IP4=ipip\n```\n\n### 多语言支持\n\n通过修改环境变量 `NALI_LANG` 来指定使用的语言，当使用非中文语言时仅支持GeoIP2这个数据库\n\n该参数可设置的值见 GeoIP2 这个数据库的支持列表\n\n```\n# NALI_LANG=en nali 1.1.1.1\n1.1.1.1 [Australia]\n```\n\n### 工作目录\n\n设置环境变量 `NALI_HOME` 来指定工作目录，配置文件和数据库存放在工作目录下。也可在配置文件中使用绝对路径指定其他数据库路径。\n\n设置环境变量 `NALI_CONFIG_HOME` 来指定配置文件目录，`NALI_DB_HOME` 来执行数据库文件目录\n\n如果未指定相关环境变量，将使用 XDG 规范，配置文件目录在 `$XDG_CONFIG_HOME/nali`，数据库文件目录在 `$XDG_DATA_HOME/nali`\n\n```\nset NALI_HOME=D:\\nali\n\nor\n\nexport NALI_HOME=/var/nali\n```\n\n## 感谢列表\n\n- [纯真QQIP离线数据库](http://www.cz88.net)\n- [qqwry纯真数据库解析](https://github.com/yinheli/qqwry)\n- [ZX公网ipv6数据库](https://ip.zxinc.org/ipquery/)\n- [Geoip2 city数据库](https://www.maxmind.com/en/geoip2-precision-city-service)\n- [geoip2-golang解析器](https://github.com/oschwald/geoip2-golang)\n- [CDN provider数据库](https://github.com/SukkaLab/cdn)\n- [IPIP数据库](https://www.ipip.net/product/ip.html)\n- [IPIP数据库解析](https://github.com/ipipdotnet/ipdb-go)\n- [ip2region数据库](https://github.com/lionsoul2014/ip2region)\n- [IP2Location DB3 LITE](https://lite.ip2location.com/database/db3-ip-country-region-city)\n- [Cobra CLI库](https://github.com/spf13/cobra)\n\n感谢 JetBrains 提供开源项目免费License \n\n\u003ca href=\"https://www.jetbrains.com/?from=nali\"\u003e\n  \u003cimg src=\"assets/GoLand.svg\"\u003e\n\u003c/a\u003e\n\n## 作者\n\n**Nali** © [zu1k](https://github.com/zu1k), 遵循 [MIT](./LICENSE) 证书.\u003cbr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzu1k%2Fnali","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzu1k%2Fnali","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzu1k%2Fnali/lists"}