1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-22 21:29:02 +08:00
nali/README.md

271 lines
6.8 KiB
Markdown
Raw Normal View History

2020-07-17 09:05:25 +08:00
<h1 align="center">
2020-07-17 13:24:05 +08:00
<br>Nali<br>
2020-07-17 09:05:25 +08:00
</h1>
2020-07-18 14:34:46 +08:00
<h4 align="center">An offline tool for querying IP geographic information and CDN provider.</h4>
2020-07-17 09:05:25 +08:00
<p align="center">
<a href="https://github.com/zu1k/nali/actions">
<img src="https://img.shields.io/github/workflow/status/zu1k/nali/Go?style=flat-square" alt="Github Actions">
</a>
<a href="https://goreportcard.com/report/github.com/zu1k/nali">
<img src="https://goreportcard.com/badge/github.com/zu1k/nali?style=flat-square">
</a>
<a href="https://github.com/zu1k/nali/releases">
<img src="https://img.shields.io/github/release/zu1k/nali/all.svg?style=flat-square">
</a>
</p>
2020-07-19 08:00:20 +08:00
#### [中文文档](https://github.com/zu1k/nali/blob/master/README_zh-CN.md)
2020-07-19 07:59:42 +08:00
2020-07-19 20:17:14 +08:00
## Origin
Inspired by [Nali C version](https://github.com/meteoral/Nali) and [nali-cli javascript version](https://github.com/SukkaW/nali-cli).
I want to query the IP geographic information and CDN service provider on the terminal, then found the Nali tool. Nali mean 'where' in Chinese, good name for this kind of tools.
However the C version has too few functions, and the js version of Sukka is too big and the supported platforms are not complete, so I rewrite it in golang, add IPv6 support and Geoip2 database.
2020-07-17 13:24:05 +08:00
## Feature
- Chunzhen qqip database
2020-07-18 09:59:48 +08:00
- ZX ipv6 database
2020-07-17 13:24:05 +08:00
- Geoip2 city database
- Pipeline support
- Interactive query
- Offline query
2020-07-18 10:12:16 +08:00
- Both ipv4 and ipv6 supported
2020-07-18 14:32:53 +08:00
- CDN provider query
2020-07-19 20:19:07 +08:00
- Full platform support
2020-07-17 13:24:05 +08:00
2020-07-17 09:05:25 +08:00
## Install
2020-07-17 13:24:05 +08:00
### Install from source
Nali Requires Go >= 1.14. You can build it from source:
2020-07-17 09:05:25 +08:00
```sh
$ go get -u -v github.com/zu1k/nali
```
2020-07-17 13:24:05 +08:00
### Install pre-build binariy
2020-07-17 09:05:25 +08:00
Pre-built binaries are available here: [release](https://github.com/zu1k/nali/releases)
2020-07-17 13:24:05 +08:00
Download the binary compatible with your platform, unpack and copy to the directory in path
### Install from docker
```
2020-07-18 14:36:07 +08:00
docker pull docker.pkg.github.com//zu1k/nali/nali:latest
2020-07-17 13:24:05 +08:00
```
2020-07-17 09:05:25 +08:00
## Usage
2020-07-17 13:24:05 +08:00
2020-07-19 20:33:56 +08:00
<a href="https://asciinema.org/a/RFVaZ3Pwy0Qbr27msFcDYhwcD" target="_blank"><img width="520" src="https://asciinema.org/a/RFVaZ3Pwy0Qbr27msFcDYhwcD.svg" /></a>
2020-07-19 20:30:51 +08:00
2020-07-17 13:26:26 +08:00
### Query a simple IP address
2020-07-17 13:24:05 +08:00
```
$ nali 1.2.3.4
1.2.3.4 [澳大利亚 APNIC Debogon-prefix网络]
```
2020-07-17 13:26:26 +08:00
#### or use `pipe`
2020-07-17 13:24:05 +08:00
```
$ echo IP 6.6.6.6 | nali
IP 6.6.6.6 [美国 亚利桑那州华楚卡堡市美国国防部网络中心]
```
2020-07-17 13:26:26 +08:00
### Query multiple IP addresses
2020-07-17 13:24:05 +08:00
```
$ nali 1.2.3.4 4.3.2.1 123.23.3.0
1.2.3.4 [澳大利亚 APNIC Debogon-prefix网络]
4.3.2.1 [美国 新泽西州纽瓦克市Level3Communications]
123.23.3.0 [越南 越南邮电集团公司]
```
2020-07-17 13:26:26 +08:00
### Interactive query
2020-07-17 13:24:05 +08:00
use `exit` or `quit` to quit
```
$ nali
123.23.23.23
123.23.23.23 [越南 越南邮电集团公司]
1.0.0.1
1.0.0.1 [美国 APNIC&CloudFlare公共DNS服务器]
8.8.8.8
8.8.8.8 [美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器]
quit
```
2020-07-17 13:26:26 +08:00
### Use with dig
2020-07-17 13:24:05 +08:00
```
$ dig nali.lgf.im +short | nali
104.28.2.115 [美国 CloudFlare公司CDN节点]
104.28.3.115 [美国 CloudFlare公司CDN节点]
172.67.135.48 [美国 CloudFlare节点]
```
2020-07-17 13:26:26 +08:00
### Use with nslookup
2020-07-17 13:24:05 +08:00
```
$ nslookup nali.lgf.im 8.8.8.8 | nali
Server: 8.8.8.8 [美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器]
Address: 8.8.8.8 [美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器]#53
Non-authoritative answer:
Name: nali.lgf.im
Address: 104.28.3.115 [美国 CloudFlare公司CDN节点]
Name: nali.lgf.im
Address: 104.28.2.115 [美国 CloudFlare公司CDN节点]
Name: nali.lgf.im
Address: 172.67.135.48 [美国 CloudFlare节点]
```
2020-07-17 13:26:26 +08:00
### Use with any other program
2020-07-17 13:24:05 +08:00
Because nali can read the contents of the `stdin` pipeline, it can be used with any program
```
bash abc.sh | nali
```
Nali will insert ip information after ip
2020-07-18 10:06:17 +08:00
### IPV6 support
Use like ipv4
```
2020-07-18 10:53:44 +08:00
$ nslookup google.com | nali
2020-07-18 10:06:17 +08:00
Server: 127.0.0.53 [局域网 IP]
Address: 127.0.0.53 [局域网 IP]#53
Non-authoritative answer:
Name: google.com
Address: 216.58.211.110 [美国 Google全球边缘网络]
Name: google.com
Address: 2a00:1450:400e:809::200e [荷兰Amsterdam Google Inc. 服务器网段]
```
2020-07-18 14:32:53 +08:00
### Query CDN provider
2020-07-19 07:44:12 +08:00
#### Query CDN provider only
2020-07-18 14:32:53 +08:00
```
$ nslookup www.gov.cn | nali cdn
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
www.gov.cn canonical name = www.gov.cn.bsgslb.cn [白山云 CDN].
www.gov.cn.bsgslb.cn [白山云 CDN] canonical name = zgovweb.v.bsgslb.cn [白山云 CDN].
Name: zgovweb.v.bsgslb.cn [白山云 CDN]
Address: 185.232.56.148
Name: zgovweb.v.bsgslb.cn [白山云 CDN]
Address: 185.232.56.147
Name: zgovweb.v.bsgslb.cn [白山云 CDN]
Address: 2001:428:6402:21b::6
Name: zgovweb.v.bsgslb.cn [白山云 CDN]
Address: 2001:428:6402:21b::5
```
2020-07-19 07:44:12 +08:00
#### Also query IP geo
2020-07-19 07:41:58 +08:00
```
2020-07-19 07:44:12 +08:00
$ nslookup www.gov.cn | nali
2020-07-19 07:41:58 +08:00
Server: 127.0.0.53 [局域网 IP]
Address: 127.0.0.53 [局域网 IP]#53
Non-authoritative answer:
www.gov.cn canonical name = www.gov.cn.bsgslb.cn [白山云 CDN].
www.gov.cn.bsgslb.cn [白山云 CDN] canonical name = zgovweb.v.bsgslb.cn [白山云 CDN].
Name: zgovweb.v.bsgslb.cn [白山云 CDN]
2020-07-19 07:44:12 +08:00
Address: 103.104.170.25 [新加坡 ]
2020-07-19 07:41:58 +08:00
Name: zgovweb.v.bsgslb.cn [白山云 CDN]
Address: 2001:428:6402:21b::5 [美国Louisiana州Monroe Qwest Communications Company, LLC (CenturyLink)]
Name: zgovweb.v.bsgslb.cn [白山云 CDN]
Address: 2001:428:6402:21b::6 [美国Louisiana州Monroe Qwest Communications Company, LLC (CenturyLink)]
```
2020-07-18 14:32:53 +08:00
#### Use standalone
You should parse cname by yourself
```
$ nali cdn cdn.somecdncname.com
```
2020-07-17 13:24:05 +08:00
## Interface
2020-07-17 13:26:26 +08:00
### Help
2020-07-17 13:24:05 +08:00
```
$ nali --help
Usage:
nali [flags]
nali [command]
Available Commands:
2020-07-18 14:32:53 +08:00
cdn Query cdn service provider
2020-07-17 13:24:05 +08:00
help Help about any command
parse Query IP information
update update chunzhen ip database
Flags:
-h, --help help for nali
-t, --toggle Help message for toggle
Use "nali [command] --help" for more information about a command.
```
2020-07-17 13:27:47 +08:00
### Update chunzhen IP database
2020-07-17 13:24:05 +08:00
```
$ nali update
2020/07/17 12:53:46 正在下载最新纯真 IP 库...
2020/07/17 12:54:05 已将最新的纯真 IP 库保存到本地 /root/.nali/qqwry.dat
```
2020-07-17 13:36:09 +08:00
### Use Geoip2 database
Set environment variables `NALI_DB`
supported database:
- Geoip2 `['geoip', 'geoip2', 'geo']`
- Chunzhen `['chunzhen', 'qqip', 'qqwry']`
#### Windows
```
set NALI_DB=geoip
```
#### Linux
```
export NALI_DB=geoip
```
2020-07-17 13:26:26 +08:00
## Thanks
- [纯真QQIP离线数据库](http://www.cz88.net/fox/ipdat.shtml)
- [qqwry mirror](https://qqwry.mirror.noc.one/)
- [qqwry纯真数据库解析](https://github.com/yinheli/qqwry)
2020-07-18 09:59:48 +08:00
- [ZX公网ipv6数据库](https://ip.zxinc.org/ipquery/)
2020-07-17 13:26:26 +08:00
- [Geoip2 city数据库](https://www.maxmind.com/en/geoip2-precision-city-service)
2020-07-17 18:00:30 +08:00
- [geoip2-golang解析器](https://github.com/oschwald/geoip2-golang)
2020-07-18 14:32:53 +08:00
- [CDN provider数据库](https://github.com/SukkaLab/cdn)
2020-07-17 13:26:26 +08:00
- [Cobra CLI库](https://github.com/spf13/cobra)
- [Nali-cli](https://github.com/SukkaW/nali-cli)
2020-07-17 13:24:05 +08:00
## License
MIT