Sign inSign up

andreaskoch/myip-cli

By andreaskoch

•Updated over 10 years ago

A small tool that returns your current local or remote IP address

Image
1

797

andreaskoch/myip-cli repository overview

⁠myip

A small tool that returns your current local or remote IP addresses

myip is a tiny, cross-platform command-line utility that just returns your current IP address (local or remote) for Linux, Windows and Mac.

⁠Motivation

Of course there are many ways to determine your current local or remote IP address. But all of them (afaik) require some scripting and string extraction and would not work the same way on all platforms.

I created this really simple tool to do just that: Get the current IP address - on all operating systems.

⁠Usage

myip <action> [options]

Actions:

  • local: Get your local IP address
  • remote: Get your remote IP address

Options:

  • -4: Use IPv4 instead of IPv6 (optional)
  • -select: Select one or more IPs (optional)
    • all: Returns all IP addresses
    • first: Returns only the first IP address
    • last: Returns only the last IP address
    • 2: Return only the second IP address
    • 1,2,3: Return only the first three IP addresses
    • 3,2,1: Return only the first three IP addresses in reverse order
    • 3: Return only the third IP address
⁠Get Help

Get help and usage information:

myip

or

myip -h
⁠Get the current local IP(s)

Get the current local IP addresses:

myip local

Get only the first local IP address:

myip local -select first

or

myip local -select 1
⁠Get the current remote IP(s)

Get the current remote IP address:

myip remote
⁠IPv6 vs. IPv4

myip will only return IPv6 addresses by default. If you want myip to return an IPv4 address you must add the -4 flag.

Examples:

myip local -4
myip remote -6

⁠Installation

If you have go⁠ installed:

git clone [email protected]:andreaskoch/myip-cli.git && cd myip-cli
go run make.go -install

or

go get github.com/andreaskoch/myip-cli

⁠Build

You can use to included make.go-script to cross-compile myip for darwin, linux and windows (amd64, arm, arm5, arm6, arm7):

go run make.go -crosscompile

If you don't have golang installed but have docker⁠ instead you can use docker to build/cross-compile myip:

git clone [email protected]:andreaskoch/myip-cli.git && cd myip-cli
docker run \
       --rm \
       -v `pwd`:/go/src/github.com/andreaskoch/myip-cli \
       --workdir=/go/src/github.com/andreaskoch/myip-cli \
       golang:latest \
       make crosscompile

Or you can extract the binaries from the automatically built andreaskoch/myip-cli⁠ docker image:

docker run --rm -v `pwd`:/exchange andreaskoch/myip-cli:latest bash -c "cp -a /go/src/github.com/andreaskoch/myip-cli/bin/* /exchange"

↑ This command will copy the binaries from the docker container to your current directory.

⁠Dependencies

myip-cli uses github.com/andreaskoch/myip⁠ for determining your local and remote IP addresses.

Tag summary

Content type

Image

Digest

Size

260.2 MB

Last updated

over 10 years ago

docker pull andreaskoch/myip-cli