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]
local: Get your local IP address
remote: Get your remote IP address
-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 and usage information:
Get the current local IP(s)
Get the current local IP addresses:
Get only the first local IP address:
myip local -select first
myip local -select 1
Get the current remote IP(s)
Get the current remote IP address:
IPv6 vs. IPv4
myip will only return IPv6 addresses by default. If you want myip to return an IPv4 address you must add the
myip local -4 myip remote -6
If you have go installed:
git clone firstname.lastname@example.org:andreaskoch/myip-cli.git && cd myip-cli go run make.go -install
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@example.com: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.