5

Github GitHub - ipinfo/cli: Official Command Line Interface for the IPinfo API (...

 3 years ago
source link: https://github.com/ipinfo/cli
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

IPinfo CLI

This is the official CLI for the IPinfo.io IP address API, allowing you to:

  • Look up IP details in bulk or one-by-one.
  • Look up ASN details.
  • Summarize the details of up to 1000 IPs at a time.
  • Open a map of IP locations for any set of IPs.
  • Filter IPv4 & IPv6 addresses from any input.
  • Print out IP lists for any CIDR or IP range.
  • And more!

Installation

All CLI tools (e.g. ipinfo, grepip) are available for download via multiple mechanisms.

macOS (amd64)

$ curl -Ls https://github.com/ipinfo/cli/releases/download/ipinfo-1.1.1/macos.sh | sh

Debian / Ubuntu (amd64)

$ curl -Ls https://github.com/ipinfo/cli/releases/download/ipinfo-1.1.1/deb.sh | sh
$ curl -LO https://github.com/ipinfo/cli/releases/download/ipinfo-1.1.1/ipinfo_1.1.1.deb
$ sudo dpkg -i ipinfo_1.1.1.deb

Using go get

Make sure that $GOPATH/bin is in your $PATH, because that's where this gets installed:

$ go get github.com/ipinfo/cli/ipinfo

Using curl/wget

The pre-built binaries for all platforms are available on GitHub via artifacts in releases. You need to simply download, unpack and move them to your shell's binary search path.

The following OS & arch combinations are supported (if you use one not listed on here, please open an issue):

darwin_amd64
darwin_arm64
dragonfly_amd64
freebsd_amd64
freebsd_arm
freebsd_arm64
linux_amd64
linux_arm
linux_arm64
netbsd_amd64
netbsd_arm
netbsd_arm64
openbsd_amd64
openbsd_arm
openbsd_arm64
plan9_amd64
plan9_arm
solaris_amd64
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/ipinfo/cli/releases/download/ipinfo-1.1.1/ipinfo_1.1.1_${PLAT}.tar.gz
# OR
$ wget https://github.com/ipinfo/cli/releases/download/ipinfo-1.1.1/ipinfo_1.1.1_${PLAT}.tar.gz

$ tar -xvf ipinfo_1.1.1_${PLAT}.tar.gz
$ mv ipinfo_1.1.1_${PLAT} /usr/local/bin/ipinfo

Using git

Installing from source requires at least the Golang version specified in go.mod. You can install the Golang toolchain from the official site.

Once the correct Golang version is installed, simply clone the repository and install the binary:

$ git clone https://github.com/ipinfo/cli ipinfo-cli
$ cd ipinfo-cli
$ go install ./ipinfo/
$ $GOPATH/bin/ipinfo

You can add $GOPATH/bin to your $PATH to access ipinfo directly from anywhere.

Alternatively, you can do the following to output the binary somewhere specific:

$ git clone https://github.com/ipinfo/cli ipinfo-cli
$ cd ipinfo-cli
$ go build -o <path> ./ipinfo/

Replace <path> with the required location.

Quick Start

Default Help Message

By default, invoking the CLI shows a help message:

Login

If you have a token, log in with it first. You can continue without a token, but there will be limited data output and some features (like bulk lookups) will not be available. Get your token for free at https://ipinfo.io/signup.

$ ipinfo login

You can quickly look up details of your own IP with myip:

Any IP

You can see the details of any IP by specifying it:

Piping

You can pipe IPs in and get their results in bulk (this requires a token):

Here's the CSV version of that:

Field Filter

In case you only needed a single field from a bunch of IPs:

The above commands implicitly run the bulk subcommand on the input. You can manually specify bulk and input IPs on the command line:

Summarize

IP details can be summarized similar to what's provided by https://ipinfo.io/summarize-ips:

There are many more features available, so for full details, consult the -h or --help message for each command. For example:

$ ipinfo 8.8.8.8 --help

Disabling Color Output

All our CLIs respect either the --nocolor flag or the NO_COLOR environment variable to disable color output.

Other IPinfo Tools

There are official IPinfo client libraries available for many languages including PHP, Python, Go, Java, Ruby, and many popular frameworks such as Django, Rails and Laravel. There are also many third party libraries and integrations available for our API.

See https://ipinfo.io/developers/libraries for more details.

About IPinfo

Founded in 2013, IPinfo prides itself on being the most reliable, accurate, and in-depth source of IP address data available anywhere. We process terabytes of data to produce our custom IP geolocation, company, carrier and IP type data sets. Our API handles over 12 billion requests a month for 100,000 businesses and developers.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK