Open source address:github.com/zu1k/nali

source

The tool is inspired by the Nali C version and the Nali – CLI JS version.

I want to query IP geographic information and CDN service provider at the terminal, and found the tool Nali. Where does Nali sound like, which is very suitable for this kind of tool

After simple use, I found that the original C language version lacked functions, and the JS version package of Sukkaka was too big to support, but the platform was very limited. Therefore, I rewrote this tool with Golang, adding IPv6 support and Geoip2 database on the basis of the original functions

function

  • Pure IPv4 offline database
  • ZX IPv6 offline database
  • Geoip2 City Database (optional)
  • IPIP database (Optional)
  • CDN service provider query
  • Support pipeline processing
  • Support for interactive queries
  • Both IPv4 and IPv6 are supported
  • Query completely offline
  • Full platform support

The installation

Install from source

Nali requires Go to be pre-installed. Once installed, you can install the software from source code:

$ go get -u -v github.com/zu1k/nali
Copy the code

Download a precompiled executable program

You can download the precompiled executable from the Release page: Release

You’ll need to download a version that fits your system and hardware architecture, unpack it and run it directly

Use the Docker version

docker pull docker.pkg.github.com//zu1k/nali/nali:latest
Copy the code

Directions for use

Example Query the geographic information of an IP address

$ nali 1.2.3.4
1.2.3.4 [澳大利亚 APNIC Debogon-prefix网络]
Copy the code

Or useThe pipe

$ echoIP 6.6.6.6 | nali IP 6.6.6.6 [Arizona HuaChu card, the department of defense network center]Copy the code

Query the geographic information of multiple IP addresses at the same time

$nali 1.2.3.4 4.3.2.1 123.23.3.0 1.2.3.4 [APNIC debogon-prefix network] 4.3.2.1 [Level3Communications, Newark, nj, USA] 123.23.3.0 [Vietnam Posts and Telecommunications Corporation]Copy the code

Interactive query

Use exit or quit to exit the query

$nali 123.23.23.23 123.23.23.23 [Vietnam post and telecommunications corporation] 1.0.0.1 1.0.0.1 [us APNIC&CloudFlare public DNS server] 8.8.8.8 8.8.8.8 [us Google DNS server in Mountain View, Santa Clara County, California] quitCopy the code

withdigCommand combination

You need to have the DIG program installed in your system

$dig nali. LGF. Im + short | nali 104.28.2.115] [American CloudFlare CDN node 104.28.3.115 172.67.135.48 [American CloudFlare CDN node] [US CloudFlare node]Copy the code

withnslookupCommand combination

You need to have nsLookup installed on your system

$nslookup nali. LGF. Im 8.8.8.8 | nali Server: 8.8.8.8 [California Santa Clara county mountain city Google company] DNS Server Address: 8.8.8.8 [Google DNS Server in Mountain View, Santa Clara County, California, USA]# 53Authoritative Answer: Name: nali.lgf.im Address: 104.28.3.115 [CloudFlare CDN] Name: Nali.lgf. im Address: aa [CloudFlare CDN node] Name: nali.lgf.im Address: 172.67.135.48Copy the code

Use with any program

Because NALI supports pipeline processing, it can be used with any program

bash abc.sh | nali
Copy the code

Nali will insert IP geographic information after THE IP and CDN service provider information after the CDN domain name

Supports IPv6

Same as IPv4

$nslookup google.com | nali Server: 127.0.0.53 / LAN IP Address: 127.0.0.53 [LAN IP]# 53Authoritative Answer: Name: google.com Address: 216.58.211.110 [aA] Name: Google.com Address: aa 2a00:1450:400e:809::200e [Amsterdam]Copy the code

Query the CDN service provider

Because CDN service usually uses the domain name resolution method of CNAME, it is recommended to use it together with NSLookup or DIG. After CNAME is known, it can be used independently

Query only the CDN service provider

$nslookup www.gov.cn | nali CDN Server: 127.0.0.53 Address: 127.0.0.53# 53Non-authoritative answer: www.gov.cn canonical name = www.gov.cn.bsgslb.cn [CDN]. www.gov.cn.bsgslb.cn canonical name = V.bsgslb.cn [bsgslb.cn] Address: 185.232.56.148 Name: [bsgslb.cn] Address: 185.232.56.147 Name: zgovweb.v.bsgslb.cn [bsgslb.cn] Address: 2001:428:6402:21B ::6 Name: zgovweb.v.bsgslb.cn [Baishanyun CDN] Address: 2001:428:6402:21B ::5Copy the code

Querying all Information

$nslookup www.gov.cn | nali Server: 127.0.0.53 / LAN IP Address: 127.0.0.53 [LAN IP]# 53Non-authoritative answer: www.gov.cn canonical name = www.gov.cn.bsgslb.cn [CDN]. www.gov.cn.bsgslb.cn canonical name = V.bsgslb.cn [bsgslb.cn] Address: 103.104.170.25 [Singapore] Address: Zgovweb.v.bsgslb.cn [Baishanyun CDN] Address: 2001:428:6402:21B ::5 [Monroe Qwest Communications Company, LLC (CenturyLink)] Name: Zgovweb.v.bsgslb.cn [Baishanyun CDN] Address: 2001:428:6402:21B ::6 [Monroe Qwest Communications Company, LLC (CenturyLink)]Copy the code

Used alone

You need to obtain the CNAME domain name in advance

$ nali cdn cdn.somecdncname.com
Copy the code

The user interaction

See the help

$ nali --help
Usage:
  nali [flags]
  nali [command]

Available Commands:
  cdn         Query cdn service provider
  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.
Copy the code

Updated pure database

$nali update 2020/07/17 12:53:46 Downloading the latest pure IP library... 2020/07/17 12:54:05 The latest pure IP library has been saved to /root/.nali/qqwry. DatCopy the code

Use the Geoip2 database

The environment variable NALI_DB needs to be set

Supported variables:

  • Geoip2 ['geoip', 'geoip2', 'geo']
  • Chunzhen ['chunzhen', 'qqip', 'qqwry']

The Windows platform

Use the GeoIP database
set NALI_DB=geoip
Copy the code
Use the IPIP database
set NALI_DB=ipip
Copy the code

Linux platform

Use the GeoIP database
export NALI_DB=geoip
Copy the code
Use the IPIP database
export NALI_DB=ipip
Copy the code

Thank you for the list

  • Pure QQIP offline database
  • qqwry mirror
  • Qqwry pure database analysis
  • ZX Public network ipv6 database
  • Geoip2 City database
  • Geoip2 – golang parser
  • CDN Provider database
  • IPIP database
  • IPIP database parsing
  • Cobra CLI library
  • Nali-cli

Open source certificate

MIT