ips is a command-line tool and library that facilitates the querying, dumping, and packaging of IP geolocation databases.
中文 | English
go install github.com/sjzar/ips@latest
Download the latest binary files from GitHub Releases.
brew tap sjzar/tap
brew install ips
- One-click querying, dumping, and packaging of IP geolocation databases
- Compatibility with multiple database formats
- Querying through command-line arguments or piping
- Output in both text and JSON formats
- Customizable query fields with persistent configuration
- Flexible database field rewriting: add or remove fields and modify content as needed
Database | Query | Dump | Pack | Official Website | Command |
---|---|---|---|---|---|
txt | ✅ | ✅ | ✅ | - | Used for project dumps |
ipdb | ✅ | ✅ | ✅ | Link | |
mmdb | ✅ | ✅ | ✅ | Link | |
awdb | ✅ | ✅ | - | Link | |
qqwry | ✅ | ✅ | - | Link | IPv4 only |
zxinc | ✅ | ✅ | - | Link | IPv6 only |
ip2region | ✅ | ✅ | - | Link | IPv4 only |
For more detailed usage instructions, please refer to usage_en.md.
# 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"}}
# 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
# 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
ips
is open-source software licensed under the Apache-2.0 License.
- IPIP.net for the ipdb database format
- MaxMind for the mmdb database format
- 埃文科技 for the awdb database format
- 纯真网络 for the qqwry database format
- ip.zxinc.org for the zxinc database format
- @lionsoul2014 for the ip2region database format
- @zu1k for the nali project, from which this project's querying feature was inspired
- @metowolf for the qqwry.dat and ipdb project
- GeoNames.org for the geolocation data
- Contributors of various Go open-source libraries, such as cobra, viper, logrus, progressbar, etc.