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
go install github.com/sjzar/ips@latest
Binary Installation
Download the latest binary files from GitHub Releases.
Homebrew Installation
brew tap sjzar/tapbrew install ips
Usage
Query
# Basic queryips <ip or text> [flags]
# Query IPips 61.144.235.160# Output:61.144.235.160 [中国 广东 深圳 电信]
# Query IP using pipelineecho "61.144.235.160" | ips# Output:61.144.235.160 [中国 广东 深圳 电信]
# Query IP using a specific database fileips -d ./GeoLite2-City.mmdb 61.144.235.160# Output:61.144.235.160 [中国 广州]
# Query IP using a specific database file and fieldsips -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 formatips -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
# Basic dump command, output dump contentips dump -i ./qqwry.dat# Output:# # Dump Time: 2023-10-20 00:00:00# # Fields: country,area# ... <omitted part of the output> ...
# Specify fields for dumpingips 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 fileips dump -i ./qqwry.dat -o 1.txt
Pack
# Package from dump fileips pack -i qqwry.txt -o qqwry.ipdb
# Package from database fileips pack -i qqwry.dat -o qqwry.ipdb
# Package from database file specifying fieldsips pack -i qqwry.dat -f country -o country.ipdb
Detailed Commands and Configuration
- Config Command - Introduces the configuration parameters and configuration file for IPS.
- Download Command - Download IP geolocation databases.
- Dump Command - Dump IP geolocation databases.
- Pack Command - Package IP geolocation databases.
- Query Command - Query IP geolocation information.
- MDNS Command - Query Multi-Geolocations DNS resolution results.
- Server Command - Start the IPS service.
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.