Operations 11 min read

Nali – Go‑Based Open‑Source CLI for Offline IP and CDN Lookup

Nali is a Go‑rewritten open‑source terminal tool that lets you query IPv4/IPv6 geolocation and CDN provider information offline using multiple databases, supports pipe processing and interactive mode, and can be installed from source or pre‑compiled binaries with configurable environment variables.

Linux Tech Enthusiast
Linux Tech Enthusiast
Linux Tech Enthusiast
Nali – Go‑Based Open‑Source CLI for Offline IP and CDN Lookup

Project

https://github.com/zu1k/nali

Features

Supports multiple offline databases: pure IPv4 (qqwry), ZX IPv6, optional GeoIP2 city, IPIP, ip2region, DB‑IP, IP2Location.

CDN service‑provider lookup.

Pipe processing for integration with other commands.

Interactive query mode.

Simultaneous IPv4 and IPv6 support.

Multi‑language output (non‑Chinese languages use GeoIP2 only).

Fully offline operation.

Cross‑platform support.

Colorful terminal output.

Installation

From source

$ go install github.com/zu1k/nali@latest

Pre‑compiled binary

Download the appropriate binary from the Release page, unzip, and run directly.

Usage

Single IP query

$ nali 1.2.3.4
1.2.3.4 [Australia APNIC Debogon‑prefix network]

Pipe input

$ echo 6.6.6.6 | nali
6.6.6.6 [United States Arizona ...]

Multiple IPs

$ nali 1.2.3.4 4.3.2.1 123.23.3.0
1.2.3.4 [Australia APNIC ...]
4.3.2.1 [United States New Jersey Level3 Communications]
123.23.3.0 [Vietnam Vietnam Post and Telecommunications Group]

Interactive mode

$ nali
123.23.23.23
123.23.23.23 [Vietnam Vietnam Post and Telecommunications Group]
1.0.0.1
1.0.0.1 [United States APNIC&CloudFlare public DNS]
8.8.8.8
8.8.8.8 [United States California Mountain View Google DNS]
quit

Combine with dig

$ dig nali.zu1k.com +short | nali
104.28.2.115 [United States CloudFlare CDN node]
104.28.3.115 [United States CloudFlare CDN node]
172.67.135.48 [United States CloudFlare node]

Combine with nslookup

$ nslookup nali.zu1k.com 8.8.8.8 | nali
Server: 8.8.8.8 [United States California Mountain View Google DNS]
Address: 8.8.8.8 [United States California Mountain View Google DNS]
Non‑authoritative answer:
Name: nali.zu1k.com
Address: 104.28.3.115 [United States CloudFlare CDN node]
Address: 104.28.2.115 [United States CloudFlare CDN node]
Address: 172.67.135.48 [United States CloudFlare node]

Configuration

On first run Nali creates ~/.nali/config.yaml. The file defines the database list; the default configuration works without modification. Example entry:

- name: geoip
  name-alias:
  - chunzhen
  - qqwry
  - ipip
  - ip2region
  - i2r
  - dbip
  - db-ip
  - ip2location
  format: mmdb
  file: GeoLite2-City.mmdb
  languages:
  - ALL
  types:
  - IPv4
  - IPv6

To add a new database, edit the file carefully; issues can be opened on the repository.

Database update

$ nali update
2020/07/17 12:53:46 Downloading latest pure IPv4 database...
2020/07/17 12:54:05 Saved to /root/.nali/qqwry.dat

Specific databases can be updated:

$ nali update --db qqwry,cdn

Environment variables

NALI_DB_IP4

/ NALI_DB_IP6 – select the database for IPv4/IPv6. NALI_LANG – set output language (non‑Chinese languages only support GeoIP2). NALI_HOME – change the working directory where databases are stored (default ~/.nali).

Supported databases

Pure IPv4 (qqwry)

ZX IPv6

GeoIP2 city (optional)

IPIP (optional)

ip2region (optional)

DB‑IP (optional)

IP2Location DB3 LITE (optional)

CDN lookup

Because CDN providers use CNAME records, combine dig or nslookup with nali to resolve the underlying IP and display the CDN provider.

$ nslookup www.gov.cn | nali
Server: 127.0.0.53 [Local IP]
Address: 127.0.0.53 [Local IP]
Non‑authoritative answer:
www.gov.cn  canonical name = www.gov.cn.bsgslb.cn [BaiShan Cloud CDN].
... (subsequent CNAME chain and IP addresses with provider tags)

Multi‑language output

Set NALI_LANG to a language code; when a non‑Chinese language is selected, only the GeoIP2 database is used.

# NALI_LANG=en nali 1.1.1.1
1.1.1.1 [Australia]

Working directory

Databases default to ~/.nali. Override the location with NALI_HOME or specify absolute paths in config.yaml.

Reference

https://github.com/zu1k/nali/releases
CLIGonetwork-toolsoffline databaseGeoIPIP lookup
Linux Tech Enthusiast
Written by

Linux Tech Enthusiast

Focused on sharing practical Linux technology content, covering Linux fundamentals, applications, tools, as well as databases, operating systems, network security, and other technical knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.