Introduction

Install the ip2geo command line, sign in, and locate IP addresses, domains and networks from your terminal.

The ip2geo CLI brings the SDK, the free tools and the whole dashboard to your terminal. Locate one address or a million, resolve domains, look networks up in the ASN directory, and manage your projects, keys, websites, team and billing, without opening a browser.

Bash
$ ip2geo 8.8.8.8
8.8.8.8  · IPv4

  Location        Mountain View, California, United States 🇺🇸 (US)
  Coordinates     37.4056, -122.0775 (within 1,000 km)
  Time zone       America/Los_Angeles (14:26 there now)
  Network         AS15169 · Google LLC

Installation

Bash
npm install -g @ip2geo/cli

The CLI runs on Node.js 20 or newer, or on Bun, and has no dependencies. On a machine with Bun but no Node.js, run it as bunx --bun @ip2geo/cli.

Sign in

Converting an address needs either a login or a secret key. Sign in with the email of your ip2geo account, the same way the dashboard’s email sign-in works:

Bash
ip2geo login

You get a 6-digit code by email, and the CLI keeps the session on your machine. Accounts created with Google or GitHub sign in with the same email address. A first sign-in creates the account, with its first project, as it does on the website.

A code expires after 10 minutes and takes 5 tries; after the fifth wrong one, run ip2geo login again for a new code. Signing In has the full rules.

Logged in, conversions run on your current project, 50 addresses per request. For bulk work, create a secret key for the CLI, which converts 5,000 addresses per request:

Bash
ip2geo keys create "My laptop" --use

You can also hand the CLI any secret key with --key, the IP2GEO_API_KEY variable or ip2geo config set api-key. Only secret keys (i2g_sk_) work here: public keys only work in a browser, on their website’s domain.

A key only reaches its own project. Naming another one with --project or IP2GEO_PROJECT converts through your login on that project, and without a login the CLI refuses rather than spend the key’s project.

On a server or in CI, where there is no terminal to type the code into, sign in in two steps: ip2geo login --email you@example.com sends the code, and ip2geo login --email you@example.com --code 123456 finishes. Most automation is simpler with a secret key in IP2GEO_API_KEY.

Quick lookups

Bash
ip2geo 8.8.8.8                               # one address, in full
ip2geo 8.8.8.8 1.1.1.1 2606:4700:4700::1111  # several, as a table
cat ips.txt | ip2geo -o csv > locations.csv  # any number, from a pipe or a file
ip2geo 8.8.8.8 --fields country_code         # one field, ready for a script
ip2geo me                                    # the address you connect from
ip2geo github.com                            # a domain's addresses, located
ip2geo dns github.com --type MX,TXT          # its DNS records
ip2geo AS13335                               # a network from the ASN directory
ip2geo ipv6 8.8.8.8                          # every IPv4 and IPv6 notation

Domains, DNS records, the ASN directory and IP notations are free and need no sign-in. Values that are not IP addresses are never sent, so a typo never costs a conversion.

Next steps

Every command is listed in Commands, and Scripting covers output formats, exit codes and configuration. ip2geo help and ip2geo <command> --help show the same from the terminal.

Get Started

Convert IPs into accurate location data in milliseconds.

Sign up today and get 1,000 free monthly conversions, and discover why developers trust us for fast, reliable, and affordable IP conversions.