Explore our IP Address Database Downloads for instant access to our IP address insights

Learn more
  1. IPinfo
  2. Blog
  3. IPinfo CLI: Lookup IP or ASN details - IPinfo.io blog
IPinfo CLI: Lookup IP or ASN details - IPinfo.io blog
3 years ago by IPinfo Team 4 min read

IPinfo CLI: Lookup IP or ASN details

The official IPinfo CLI is just one of the ways we prioritize developers and their work. In 2021, we shared a broad overview of the commands you can use within our CLI. We also shared a guide about how to filter IPs using [grepip](<https://github.com/ipinfo/cli/releases/tag/grepip-1.1.0>), a specialized version of grep that gives developers more flexible filtering options.

Now let’s talk about IP and ASN lookups - how to conduct a lookup, how to do bulk lookups, and how these commands can help in developer workflows.

Why CLI-based IP and ASN lookups matter

Developers looking to quickly debug something will usually find home in their terminal, but some things, like IP and ASN data lookups, tend to really sophisticated and require lots of custom code to even get started.

With the IPinfo CLI, getting and debugging data on IP addresses or ASNs becomes too easy. The CLI is designed to fit right in with other commands by being trivially pluggable with other commands in shell pipes and generally being really flexible in how input is parsed.

How to conduct a single lookup

You can lookup IPs (including your own, if you need to know it) using the CLI in many ways.

Before you continue, you will want to run ipinfo login to login with your IPinfo API token to get all the data available to your account, and not get rate limited, nor blocked from services that require a token, like ASN and bulk lookups - if you don’t have one, see https://ipinfo.io/signup.

Here’s one quick way to get your own current live IP address:

$ ipinfo myip
Core
- IP           110.39.13.197
- Anycast      false
- Hostname     wgpon-3913-197.wateen.net
- City         Lahore
- Region       Punjab
- Country      Pakistan (PK)
- Location     31.5580,74.3507
- Organization AS38264 National WiMAX/IMS environment
- Postal       54000
- Timezone     Asia/Karachi

ASN
- ID     AS38264
- Name   National WiMAX/IMS environment
- Domain wateen.com
- Route  110.39.12.0/22
- Type   isp

Company
- Name   National WiMAX/IMS environment
- Domain wateen.com
- Type   isp

Privacy
- VPN     false
- Proxy   false
- Tor     false
- Relay   false
- Hosting false
- Service 

Abuse
- Address Wateen Telecom Limited Main Walton Road, Opp. Bab-e-Pakistan, Walton Cantt., Lahore
- Country Pakistan (PK)
- Email   Muhammad.Ashraf2@wateen.com
- Name    Muhammad Ashraf
- Network 110.39.0.0/17
- Phone   +92-321-4497383

This is the IP address the world sees you with.

Here’s another that looks up a specific IP:

$ ipinfo 8.8.8.8
Core
- IP           8.8.8.8
- Anycast      true
- Hostname     dns.google
- City         Mountain View
- Region       California
- Country      United States (US)
- Location     37.4056,-122.0775
- Organization AS15169 Google LLC
- Postal       94043
- Timezone     America/Los_Angeles

ASN
- ID     AS15169
- Name   Google LLC
- Domain google.com
- Route  8.8.8.0/24
- Type   business

Company
- Name   Google LLC
- Domain google.com
- Type   business

Privacy
- VPN     false
- Proxy   false
- Tor     false
- Relay   false
- Hosting false
- Service 

Abuse
- Address US, CA, Mountain View, 1600 Amphitheatre Parkway, 94043
- Country United States (US)
- Email   network-abuse@google.com
- Name    Abuse
- Network 8.8.8.0/24
- Phone   +1-650-253-0000

Domains
- Total    11300
- Examples aonode.com
           itempurl.com
           41.cn
           wzzh.info
           iclouddc.com

You can also use the --csv (or -c) and --json (or -j) flags to change the output format to be CSV or JSON, respectively. This allows you to pipe the output into further commands for easier automated processing.

You can also lookup ASNs in a similar manner:

$ ipinfo AS123
{
  "asn": "AS123",
  "name": "Air Force Systems Networking",
  "country": "US",
  "allocated": "1987-08-24",
  "registry": "arin",
  "domain": "af.mil",
  "num_ips": 0,
  "type": "inactive",
  "prefixes": [],
  "prefixes6": [],
  "peers": null,
  "upstreams": null,
  "downstreams": null
}

Active ASNs will have very large arrays of data.

How to get bulk lookups

We can lookup multiple IP addresses in bulk if needed, which is a very common case when doing heavy data processing on the shell.

You can pipe IPs into the CLI directly:

$ echo -e '1.1.1.1\\n8.8.8.8' | ipinfo -f hostname
ip,hostname
1.1.1.1,one.one.one.one
8.8.8.8,dns.google

You can also explicitly specify those IPs directly into the CLI via arguments:

$ ipinfo bulk -f hostname 1.1.1.1 8.8.8.8
ip,hostname
1.1.1.1,one.one.one.one
8.8.8.8,dns.google

In fact, you can go a bit crazy with this - you can input via pipes, specify individual IPs, CIDRs, IP ranges, and file arguments, all simultaneously!

$ cat ips.txt | ipinfo bulk -f ip,hostname 1.1.1.1,1.1.1.4 8.8.8.1-8.8.8.3 3.3.3.0/31 1.1.1.1 3.3.3.3 ips.txt 
ip,hostname
8.8.8.8,dns.google
8.8.8.1,
3.3.3.0,
1.1.1.1,one.one.one.one
1.1.1.4,
3.3.3.1,
4.4.4.4,
3.3.3.3,
2.2.2.2,
1.1.1.3,
1.1.1.2,
8.8.8.2,
8.8.8.3,

The bulk lookup command is really very powerful.


IPinfo is a comprehensive IP address data and API provider with flexible pricing plans to meet your business needs. We handle billions of API requests per month, serving data like IP geolocation, VPN detection, ASN, and more. Sign up for a free account or contact our team to learn more.