Function
-
Support multiple databases
-
Pure IPv4 Offline Database
-
ZX IPv6 offline database
-
Geoip2 city database (optional)
-
IPIP database (optional)
-
ip2region database (optional)
-
DB-IP database (optional)
-
IP2Location DB3 LITE database (optional)
-
-
CDN Service Provider Inquiry
-
Supports pipelining
-
Support for interactive query
-
Supports both IPv4 and IPv6
-
Support multiple languages
-
Queries are completely offline
-
Full platform support
-
Support color output
Install
Install from source
Nali requires Go >= 1.19 to be pre-installed. After installation, you can install the software from source:
$ go install github.com/zu1k/nali@latest
Download a precompiled executable
You can download precompiled executables from the Release page:
https://github.com/zu1k/nali/releases
You need to choose the version suitable for your system and hardware architecture to download, and you can run it directly after decompression
Arch Linux
We publish 3 related packages in Aur:
-
nali-go
: Release version, compiled during installation -
nali-go-bin
: Release version, precompiled binaries -
nali-go-git
: The latest master branch version, compiled during installation
Instructions for use
Query the geographical information of an IP
$ nali 1.2.3.4
1.2.3.4 [澳大利亚 APNIC Debogon-prefix网络]
or use 管道
$ echo IP 6.6.6.6 | nali
IP 6.6.6.6 [美国 亚利桑那州华楚卡堡市美国国防部网络中心]
Query geographic information of multiple IPs at the same time
$ 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 [越南 越南邮电集团公司]
interactive query
use exit
or quit
exit query
$ 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
dig
Use with the command
The dig program needs to be installed in your system
$ dig nali.zu1k.com +short | nali
104.28.2.115 [美国 CloudFlare公司CDN节点]
104.28.3.115 [美国 CloudFlare公司CDN节点]
172.67.135.48 [美国 CloudFlare节点]
nslookup
Use with the command
You need to have installed the nslookup program in your system
$ nslookup nali.zu1k.com 8.8.8.8 | nali
Server: 8.8.8.8 [美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器]
Address: 8.8.8.8 [美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器]#53
Non-authoritative answer:
Name: nali.zu1k.com
Address: 104.28.3.115 [美国 CloudFlare公司CDN节点]
Name: nali.zu1k.com
Address: 104.28.2.115 [美国 CloudFlare公司CDN节点]
Name: nali.zu1k.com
Address: 172.67.135.48 [美国 CloudFlare节点]
Use with any program
Because nali supports pipeline processing, it can be used with any program
bash abc.sh | nali
Nali will insert IP geographic information after the IP, and insert CDN service provider information after the CDN domain name
Support IPv6
Exactly the same as IPv4 usage
$ nslookup google.com | nali
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. 服务器网段]
Query CDN service provider
Because the CDN service usually uses the CNAME domain name resolution method, it is recommended to use it in conjunction with nslookup
or dig
, and it can be used alone after the CNAME is already known
$ nslookup www.gov.cn | nali
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]
Address: 103.104.170.25 [新加坡 ]
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)]
User interaction
After the program runs for the first time, a configuration file config.yaml
(default ~/.nali/config.yaml
) will be generated in the working directory. The configuration file defines the database information, and the default user does not need to modify it
The default database format is as follows:
- name: geoip
name-alias:
- geolite
- geolite2
format: mmdb
file: GeoLite2-City.mmdb
languages:
- ALL
types:
- IPv4
- IPv6
Among them, languages
and types
represent the languages and query types supported by the database. If you need to add a database, you need to modify the configuration file carefully. If you have any questions, please ask for an issue.
view help
$ nali --help
Usage:
nali [flags]
nali [command]
Available Commands:
help Help about any command
update update qqwry, zxipv6wry, ip2region ip database and cdn
Flags:
-h, --help help for nali
-t, --toggle Help message for toggle
Use "nali [command] --help" for more information about a command.
update database
Update all databases that can be automatically updated
$ nali update
2020/07/17 12:53:46 正在下载最新纯真 IP 库...
2020/07/17 12:54:05 已将最新的纯真 IP 库保存到本地 /root/.nali/qqwry.dat
or specify the database
$ nali update --db qqwry,cdn
2020/07/17 12:53:46 正在下载最新纯真 IP 库...
2020/07/17 12:54:05 已将最新的纯真 IP 库保存到本地 /root/.nali/qqwry.dat
optional database
The user can specify which database to use, and the environment variable needs to be set: NALI_DB_IP4
, NALI_DB_IP6
or both at the same time
Supported variable content:
-
Geoip2
['geoip', 'geoip2']
-
Chunzhen
['chunzhen', 'qqwry']
-
IPIP
['ipip']
-
Ip2Region
['ip2region', 'i2r']
-
DBIP
['dbip', 'db-ip']
-
IP2Location
['ip2location']
Windows platform
Use geoip database
set NALI_DB_IP4=geoip
或者使用 powershell
$env:NALI_DB_IP4="geoip"
Use the ipip database
set NALI_DB_IP6=ipip
或者使用 powershell
$env:NALI_DB_IP6="ipip"
Linux platform
Use geoip database
export NALI_DB_IP4=geoip
Use the ipip database
export NALI_DB_IP4=ipip
multilingual support
NALI_LANG
Specify the language used by modifying the environment variable , when using non-Chinese language, only GeoIP2 database is supported
For the values that can be set for this parameter, see the support list of the GeoIP2 database
# NALI_LANG=en nali 1.1.1.1
1.1.1.1 [Australia]
Work list
Set environment variables NALI_HOME
to specify the working directory, configuration files and databases are stored in the working directory. You can also specify other database paths using absolute paths in the configuration file.
Set the environment variable NALI_CONFIG_HOME
to specify the configuration file directory NALI_DB_HOME
to execute the database file directory
If no relevant environment variables are specified, the XDG specification will be used, the configuration file directory is in $XDG_CONFIG_HOME/nali
, and the database file directory is in $XDG_DATA_HOME/nali
set NALI_HOME=D:\nali
or
export NALI_HOME=/var/nali
Open source address:
https://github.com/zu1k/nali