ip2asn-cli 0.1.0

CLI for the ip2asn crate.
ip2asn-cli-0.1.0 is not a library.

ip2asn-cli

A high-performance command-line interface for mapping IP addresses to Autonomous System (AS) information.

This tool provides two main functions:

  1. Lookup: Resolves one or more IP addresses, provided either as command-line arguments or via standard input. Output can be in a human-readable format or structured JSON.
  2. Update: Downloads the latest IP-to-ASN dataset from iptoasn.com, ensuring lookups are based on current data. The dataset is cached locally.

The CLI is designed to be fast, efficient, and suitable for interactive use or integration into automated shell scripts. It automatically handles caching and periodic updates of the dataset.

Usage

# Look up a single IP
# Look up a single IP (default command)
ip2asn 8.8.8.8
15169 | 8.8.8.8 | 8.8.8.0/24 | GOOGLE | US

# Look up multiple IPs from stdin
cat ips.txt | ip2asn
15169 | 8.8.8.8 | 8.8.8.0/24 | GOOGLE | US
13335 | 1.1.1.1 | 1.1.1.0/24 | CLOUDFLARENET | US

# Output in JSON format
ip2asn --json 1.1.1.1 | jq .
{
 "ip": "1.1.1.1",
 "found": true,
 "info": {
   "network": "1.1.1.0/24",
   "asn": 13335,
   "country_code": "US",
   "organization": "CLOUDFLARENET"
 }
}

# Download the latest dataset
ip2asn update