Files
ip-geolocate/README.md
T

68 lines
1.9 KiB
Markdown

# IP Geolocate
A command-line tool for IP geolocation using MaxMind's GeoLite2 databases. Provides detailed location and ISP information for any IPv4 or IPv6 address.
## Features
- **Dual database lookup**: Uses both `GeoLite2-City.mmdb` (location data) and `GeoLite2-ASN.mmdb` (ISP/autonomous system info) simultaneously
- **Comprehensive output**: Country, city, region, latitude/longitude, postal code, timezone, ISP, organization, ASN number and name
- **Cross-platform**: Works on Linux, macOS, and Windows
- **Formatted display**: ANSI-colored output with a clean result box
## Requirements
- C compiler (gcc or clang)
- libmaxminddb development headers (`libmaxminddb-dev` on Debian/Ubuntu, `libmaxminddb-devel` on Fedora/RHEL)
- MaxMind GeoLite2 database files (free download requires account registration)
## Getting the Databases
1. Create a free account at https://dev.maxmind.com/geoip/geolite2-free-geolocation-data
2. Download both databases:
- `GeoLite2-City.mmdb` — location data
- `GeoLite2-ASN.mmdb` — ISP and autonomous system info
3. Place both `.mmdb` files in the same directory as the executable
## Building
### Linux/macOS
```bash
make
```
For a debug build with AddressSanitizer:
```bash
make debug
```
To clean up build artifacts:
```bash
make clean
```
### Windows (MSVC)
```cmd
cl ip_geolocate.c maxminddb.lib ws2_32.lib
```
## Usage
```bash
./ip_geolocate <IP_ADDRESS>
```
Examples:
```bash
./ip_geolocate 8.8.8.8
./ip_geolocate 1.1.1.1
./ip_geolocate 2001:4860:4860::8888
```
## Output Example
The tool displays a formatted box with all available geolocation data for the queried IP address, including country flags (emoji), coordinates, and ISP information.
## License
This project is provided as-is for personal and educational use. The GeoLite2 databases are licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).