Operations 13 min read

Nali – Offline IP Geolocation & CDN Lookup Tool: Features, Install & Use

Nali is an open‑source Go rewrite of the original Nali C and JavaScript tools, offering offline IP geolocation and CDN provider queries with support for multiple databases, IPv4/IPv6, pipeline processing, interactive mode, multilingual output, and easy installation via source or pre‑compiled binaries across platforms.

Open Source Linux
Open Source Linux
Open Source Linux
Nali – Offline IP Geolocation & CDN Lookup Tool: Features, Install & Use

Origin

The tool is inspired by the Nali C version and the nali‑cli JavaScript version. The original C version lacked some features, and the JavaScript version was large and supported limited platforms, so the author rewrote it in Go, adding IPv6 support and the GeoIP2 database.

Project URL

https://github.com/zu1k/nali

Features

Supports 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 lookup

Pipeline processing support

Interactive query mode

Simultaneous IPv4 and IPv6 support

Multilingual output

Fully offline operation

Cross‑platform support

Colorful output

Installation

Install from source

Nali requires Go >= 1.18. After installing Go, run:

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

Download pre‑compiled binaries

Download the appropriate executable from the Release page, extract it, and run directly.

Usage

Query a single IP

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

Or use a pipeline

$ echo IP 6.6.6.6 | nali
6.6.6.6 [United States Arizona Huachuca City US Department of Defense Network Center]

Query multiple IPs at once

$ nali 1.2.3.4 4.3.2.1 123.23.3.0
1.2.3.4 [Australia APNIC Debogon‑prefix network]
4.3.2.1 [United States New Jersey Newark Level3Communications]
123.23.3.0 [Vietnam Vietnam Telecom Group]

Interactive query

Enter exit or quit to leave interactive mode.

$ nali
123.23.23.23
123.23.23.23 [Vietnam Vietnam Telecom 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

Requires dig installed.

$ 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

Requires nslookup installed.

$ 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]
Address: 104.28.2.115 [United States CloudFlare CDN]
Address: 172.67.135.48 [United States CloudFlare node]

Combine with any program

Because Nali supports pipeline processing, it can be chained with any command.

bash abc.sh | nali

IPv6 support

Usage is identical to IPv4.

$ nslookup google.com | nali
Server:          127.0.0.53 [Local network IP]
Address:         127.0.0.53 [Local network IP]
Non‑authoritative answer:
Name:   google.com
Address: 216.58.211.110 [United States Google global edge network]
Address: 2a00:1450:400e:809::200e [Netherlands Amsterdam Google Inc. server segment]

Query CDN service provider

Since CDN services usually use CNAME records, combine with nslookup or dig after obtaining the CNAME.

$ nslookup www.gov.cn | nali
Server:          127.0.0.53 [Local network IP]
Address:         127.0.0.53 [Local network IP]
Non‑authoritative answer:
www.gov.cn  canonical name = www.gov.cn.bsgslb.cn [Baishan Cloud CDN].
... (additional CNAME chain) ...
Address: 103.104.170.25 [Singapore]
Address: 2001:428:6402:21b::5 [United States Louisiana Qwest Communications (CenturyLink)]
Address: 2001:428:6402:21b::6 [United States Louisiana Qwest Communications (CenturyLink)]

User Interaction

On first run, Nali creates a configuration file config.yaml (default location ~/.nali/config.yaml) that defines database information. The default configuration works for most users.

Database configuration example

- name: geoip
  name-alias:
    - geolite
    - geolite2
  format: mmdb
  file: GeoLite2-City.mmdb
  languages:
    - ALL
  types:
    - IPv4
    - IPv6

The languages and types fields indicate supported languages and query types. Modify the configuration carefully if adding new databases.

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 databases

Update all automatically updatable databases:

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

Or update specific databases:

$ nali update --db qqwry,cdn
2020/07/17 12:53:46 Downloading latest pure IP database...
2020/07/17 12:54:05 Saved the latest pure IP database to /root/.nali/qqwry.dat

Select database (environment variables)

Set NALI_DB_IP4 and/or NALI_DB_IP6 to choose which database to use. Supported values include:

geoip / geoip2

chunzhen / qqwry

ipip

ip2region / i2r

dbip / db-ip

ip2location

Windows

Set environment variables:

set NALI_DB_IP4=geoip
# or PowerShell
$env:NALI_DB_IP4="geoip"
set NALI_DB_IP6=ipip
# or PowerShell
$env:NALI_DB_IP6="ipip"

Linux

export NALI_DB_IP4=geoip
export NALI_DB_IP4=ipip

Multilingual support

Set NALI_LANG to specify the output language. Non‑Chinese languages currently only support the GeoIP2 database.

# NALI_LANG=en nali 1.1.1.1
1.1.1.1 [Australia]

Change working directory

If NALI_HOME is not set, databases are stored in ~/.nali. Set NALI_HOME to change the location.

set NALI_HOME=D:
ali
# or
export NALI_HOME=/var/nali

References

Release: https://github.com/zu1k/nali/releases

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GoCLI toolIP geolocationoffline databasenetwork utilitiesCDN lookup
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional 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.