Skip to content

Quick Start

Welcome to IPS! This is a command-line tool and library designed to help you easily query, dump, and pack IP geolocation databases.

Download And Install

Installation from Source

Terminal window
go install github.com/sjzar/ips@latest

Binary Installation

WindowsUnixMacOS

Download the latest binary files from GitHub Releases.

Homebrew Installation

Terminal window
brew tap sjzar/tap
brew install ips

Usage

Query

Terminal window
# Basic query
ips <ip or text> [flags]
# Query IP
ips 61.144.235.160
# Output:61.144.235.160 [中国 广东 深圳 电信]
# Query IP using pipeline
echo "61.144.235.160" | ips
# Output:61.144.235.160 [中国 广东 深圳 电信]
# Query IP using a specific database file
ips -d ./GeoLite2-City.mmdb 61.144.235.160
# Output:61.144.235.160 [中国 广州]
# Query IP using a specific database file and fields
ips -d ./GeoLite2-City.mmdb --fields country 61.144.235.160
# Output:61.144.235.160 [中国]
# Query IP using a specific database file and output in JSON format
ips -d ./GeoLite2-City.mmdb --fields '*' -j 61.144.235.160
# Output:{"ip":"61.144.235.160","net":"61.144.192.0/18","data":{"city":"广州市","continent":"亚洲","country":"中国","latitude":"23.1181","longitude":"113.2539","utcOffset":"Asia/Shanghai"}}

Dump

Terminal window
# Basic dump command, output dump content
ips dump -i ./qqwry.dat
# Output:
# # Dump Time: 2023-10-20 00:00:00
# # Fields: country,area
# ... <omitted part of the output> ...
# Specify fields for dumping
ips dump -i ./qqwry.dat -f country
# Output:
# # Dump Time: 2023-10-20 00:00:00
# # Fields: country
# ... <omitted part of the output> ...
# Dump content and save to a file
ips dump -i ./qqwry.dat -o 1.txt

Pack

Terminal window
# Package from dump file
ips pack -i qqwry.txt -o qqwry.ipdb
# Package from database file
ips pack -i qqwry.dat -o qqwry.ipdb
# Package from database file specifying fields
ips pack -i qqwry.dat -f country -o country.ipdb

Detailed Commands and Configuration

Supported Database Formats

IPS supports multiple database formats. For more information about each format, please refer to the following link:

Advanced Usage

Explore the advanced uses of IPS, including trimming fields and custom database operations, please refer to Advanced Usage Examples.