A command-line tool for querying IP geolocation, ASN, network, and proxy information from the IP2Location.io API.
ip2locationio supports IPv4 and IPv6 lookups and is designed for developers who want IP intelligence directly from a terminal, shell script, CI job, or troubleshooting workflow.
Depending on the API plan, a lookup can return data such as country, region, city, ZIP/postal code, latitude and longitude, time zone, ASN, autonomous system name, ISP, domain, usage type, mobile network information, and proxy or security signals.
- Look up IPv4 and IPv6 geolocation from the command line.
- Query your own public IP address without supplying an IP argument.
- Retrieve ASN and network information alongside geolocation data.
- Output results as JSON or pretty-printed JSON.
- Select specific response fields for scripts and command-line workflows.
- Configure an API key once or pass one with
-k. - Request translated location data on supported plans.
- Generate random IPv4 addresses.
- Convert between CIDR blocks and IP ranges.
- List addresses in a CIDR or IP range.
- Split a larger CIDR into smaller CIDR blocks.
Note
Available IP attributes depend on your IP2Location.io API plan.
No API key is required for limited keyless API usage. IP2Location.io currently allows up to 1,000 keyless IP geolocation queries per day. A free API key provides up to 50,000 IP geolocation queries per month according to the Free plan.
See IP2Location.io pricing for current limits and plan details.
go install github.com/ip2location/ip2location-io-cli/ip2locationio@latestgit clone https://github.com/ip2location/ip2location-io-cli ip2location-io-cli
cd ip2location-io-cli
go install ./ip2locationio/
$GOPATH/bin/ip2locationiocurl -LO https://github.com/ip2location/ip2location-io-cli/releases/download/v1.2.0/ip2location-io-1.2.0.deb
sudo dpkg -i ip2location-io-1.2.0.debsudo add-apt-repository ppa:ip2location/ip2locationio
sudo apt update
sudo apt install ip2location-iogit clone https://aur.archlinux.org/ip2location-io-cli.git && cd ip2location-io-cli
makepkg -si
curl -Ls https://raw.githubusercontent.com/ip2location/ip2location-io-cli/main/scripts/macos.sh | sh
Launch Powershell as administrator then run the below:
iwr -useb https://raw.githubusercontent.com/ip2location/ip2location-io-cli/main/scripts/windows.ps1 | iexscoop bucket add extras
scoop install ip2location-io-cliSupported OS/architectures below:
darwin_amd64
darwin_arm64
dragonfly_amd64
freebsd_386
freebsd_amd64
freebsd_arm
freebsd_arm64
linux_386
linux_amd64
linux_arm
linux_arm64
netbsd_386
netbsd_amd64
netbsd_arm
netbsd_arm64
openbsd_386
openbsd_amd64
openbsd_arm
openbsd_arm64
solaris_amd64
windows_386
windows_amd64
windows_arm
After choosing a platform PLAT from above, run:
# for Windows, use ".zip" instead of ".tar.gz"
curl -LO https://github.com/ip2location/ip2location-io-cli/releases/download/v1.2.0/ip2locationio_1.2.0_${PLAT}.tar.gz
# OR
wget https://github.com/ip2location/ip2location-io-cli/releases/download/v1.2.0/ip2locationio_1.2.0_${PLAT}.tar.gz
tar -xvf ip2locationio_1.2.0_${PLAT}.tar.gz
mv ip2locationio_1.2.0_${PLAT} /usr/local/bin/ip2locationioip2locationio -hip2locationio config <API KEY>ip2locationioip2locationio 8.8.8.8ip2locationio -o pretty 8.8.8.8Query IP geolocation for specific IP with translation language (only supported in Plus and Security plans)
ip2locationio -l fr 8.8.8.8ip2locationio -f country_code,region_name,city_name,continent.name,country.alpha3_code 8.8.8.8ip2locationio randipip2locationio cidr2range <CIDR>ip2locationio range2cidr <START IP> <END IP>ip2locationio cidr2list <CIDR>ip2locationio range2list <START IP> <END IP>ip2locationio splitcidr <CIDR> <SPLIT>The exact response depends on your API plan. A response can include fields such as:
{
"ip": "8.8.8.8",
"country_code": "US",
"country_name": "United States of America",
"region_name": "California",
"city_name": "Mountain View",
"latitude": 37.405992,
"longitude": -122.078515,
"zip_code": "94043",
"time_zone": "-07:00",
"asn": "15169",
"as": "Google LLC",
"isp": "Google LLC",
"domain": "google.com",
"net_speed": "T1",
"idd_code": "1",
"area_code": "650",
"weather_station_code": "USCA0746",
"weather_station_name": "Mountain View",
"mcc": "-",
"mnc": "-",
"mobile_brand": "-",
"elevation": 32,
"usage_type": "DCH",
"address_type": "Anycast",
"continent": {
"name": "North America",
"code": "NA",
"hemisphere": [
"north",
"west"
],
"translation": {
"lang": "es",
"value": "Norteamérica"
}
},
"district": "Santa Clara County",
"country": {
"name": "United States of America",
"alpha3_code": "USA",
"numeric_code": 840,
"demonym": "Americans",
"flag": "https://cdn.ip2location.io/assets/img/flags/us.png",
"capital": "Washington, D.C.",
"total_area": 9826675,
"population": 331002651,
"currency": {
"code": "USD",
"name": "United States Dollar",
"symbol": "$"
},
"language": {
"code": "EN",
"name": "English"
},
"tld": "us",
"translation": {
"lang": "es",
"value": "Estados Unidos de América (los)"
}
},
"region": {
"name": "California",
"code": "US-CA",
"translation": {
"lang": "es",
"value": "California"
}
},
"city": {
"name": "Mountain View",
"translation": {
"lang": null,
"value": null
}
},
"time_zone_info": {
"olson": "America/Los_Angeles",
"current_time": "2023-09-03T18:21:13-07:00",
"gmt_offset": -25200,
"is_dst": true,
"sunrise": "06:41",
"sunset": "19:33"
},
"geotargeting": {
"metro": "807"
},
"ads_category": "IAB19-11",
"ads_category_name": "Data Centers",
"is_proxy": false,
"fraud_score": 0,
"proxy": {
"last_seen": 3,
"proxy_type": "DCH",
"threat": "-",
"provider": "-",
"is_vpn": false,
"is_tor": false,
"is_data_center": true,
"is_public_proxy": false,
"is_web_proxy": false,
"is_web_crawler": false,
"is_ai_crawler": false,
"is_residential_proxy": false,
"is_spammer": false,
"is_scanner": false,
"is_botnet": false
}
}For the complete list of available fields, see the IP2Location.io IP Geolocation API documentation.
The CLI is useful when you want to inspect IP data without writing an API client first. Typical workflows include:
- Investigating an IP address from application or server logs.
- Checking the approximate country, region, city, or time zone of an IP.
- Looking up an ASN or network operator during troubleshooting.
- Enriching IP addresses in shell scripts or development tools.
- Checking proxy or network attributes when available on your API plan.
- Converting CIDR blocks and IP ranges while working with network configuration.
IP geolocation is approximate network intelligence. It should not be treated as GPS-level location or proof of a person's physical location.
IP2Location provides two main approaches for developers who need IP geolocation or network data:
| Approach | Best for |
|---|---|
| IP2Location.io API | CLI tools, applications, scripts, and services that want a hosted IP geolocation API |
| IP2Location LITE Database | Applications that want to perform IP geolocation locally on their own infrastructure |
| ASN LITE Database | Local IP-to-ASN and autonomous system lookups |
| IP2Proxy LITE Database | Local proxy, VPN, and related network detection |
This CLI uses the IP2Location.io API.
If your application needs local database lookups instead of an external API request, see the free downloadable databases at IP2Location LITE.
Yes. IP2Location.io supports limited keyless IP geolocation queries and also provides a Free API plan for development, testing, scripts, and applications.
For local lookup workflows, developers can use the free downloadable IP2Location LITE database on their own infrastructure. ASN LITE and IP2Proxy LITE databases are also available for ASN and proxy-related lookups.
An IP geolocation API maps an IPv4 or IPv6 address to approximate geographic and network information such as country, city, coordinates, time zone, ASN, ISP, or proxy information.
Developers commonly use this data for localization, analytics, log enrichment, troubleshooting, and security context.
The CLI performs point-in-time IP address lookups; it does not continuously track users or devices.
Applications can enrich IP addresses from their own logs with location, ASN, and network information, but IP geolocation should not be treated as precise person or device tracking.
Run:
ip2locationioWith no IP argument, the CLI determines your public IP and returns its available geolocation and network information.
This CLI can retrieve IP geolocation and ASN information in the same API lookup:
ip2locationio -f ip,asn,as 8.8.8.8For applications that need local lookups, developers can also use the downloadable IP2Location LITE and ASN LITE databases.
IP geolocation estimates the location associated with an IP network. Results can be affected by VPNs, proxies, mobile carriers, corporate gateways, cloud infrastructure, and ISP routing.
Country-level information is generally more reliable than an exact city or latitude/longitude. Do not use IP geolocation coordinates as a street address or precise device location.
- IP2Location.io
- IP2Location.io IP Geolocation API Documentation
- IP2Location.io Pricing
- IP2Location LITE Databases
- IP2Location
- GitHub Releases
See the LICENSE file.