A small tool that returns your current local or remote IP address
797
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.
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.
myip <action> [options]
Actions:
local: Get your local IP addressremote: Get your remote IP addressOptions:
-4: Use IPv4 instead of IPv6 (optional)-select: Select one or more IPs (optional)
all: Returns all IP addressesfirst: Returns only the first IP addresslast: Returns only the last IP address2: Return only the second IP address1,2,3: Return only the first three IP addresses3,2,1: Return only the first three IP addresses in reverse order3: Return only the third IP addressGet help and usage information:
myip
or
myip -h
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 address:
myip remote
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
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
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.
myip-cli uses github.com/andreaskoch/myip for determining your local and remote IP addresses.
Content type
Image
Digest
Size
260.2 MB
Last updated
over 10 years ago
docker pull andreaskoch/myip-cli