Global IP detection tool for who has paranoid skeptical. Show own Public IP (a.k.a. Global IP; WAN IP; External IP) with reliability by searching multiple way.
myip supports various way to IP resolving.
- HTTP / HTTPS
- DNS
- STUN
See the target list for the bundled resolvers.
And if many of these targets answer same, then it show as true IP. So this aims to be resistant for man-in-the-middle-attack or temporary service down.
$ myip
203.0.113.2This option gives output with ending newline character.
$ myip
203.0.113.2$$ myip -n
203.0.113.2
$$ myip -V
v0.3.0
$$ myip -v
2018/01/01 12:00:00 IP:203.0.113.2 type:dns weight:2.0 A,myip.opendns.com.,resolver3.opendns.com:53
2018/01/01 12:00:00 IP:203.0.113.2 type:dns weight:2.0 A,whoami.akamai.net.,ns1-1.akamaitech.net:53
2018/01/01 12:00:00 IP:203.0.113.2 type:dns weight:2.0 TXT,o-o.myaddr.l.google.com.,ns1.google.com:53
2018/01/01 12:00:00 IP:203.0.113.2 type:stun weight:3.0 stun4.l.google.com:19302
2018/01/01 12:00:00 IP:203.0.113.2 type:http weight:0.5 http://ipcheck.ieserver.net/
.
.
.
2018/01/01 12:00:00 IP:203.0.113.2 type:https weight:3.0 https://icanhazip.com/
2018/01/01 12:00:00 IP:203.0.113.2 type:https weight:3.0 https://wtfismyip.com/text
203.0.113.2When your machine has IPv6 address, -6 option is available.
$ myip -6
2001:0db8:0000:0042:0000:8a2e:0370:7334If your machine doesn't have IPv6 address, fallbacks to IPv4.
$ myip -h
myip
Usage:
myip [-v | --verbose] [-4 | -6] [-T=<rate>] [-t=<duration>]
myip (--help | --version)
Options:
-h --help Show this screen.
-V --version Show version.
-v --verbose Verbose mode.
-4 --ipv4 Prefer IPv4.
-6 --ipv6 Prefer IPv6.
-n --newline Show IP with newline.
-N --no-newline Show IP without newline.
-T=<rate> --threshold=<rate> Threshold in [0.0, 1.0] that must be exceeded by weighted votes [default: 0.6].
-t=<duration> --timeout=<duration> Timeout [default: 3s].
If you have a Go environment, install the latest release with:
$ go install github.com/kitsuyui/myip@latestIf you don't have Golang environments or prefer single binary environment, you can use statically binary release. It has no DLL dependency. So you can use it by just downloading.
- Choose your OS here: https://github.com/kitsuyui/myip/releases
- Download and make it executable
If you encounter such as following:
- Execute
xattr -d com.apple.quarantine ./myipto remove quarantine flag set on the binary.
$ wget https://github.com/kitsuyui/myip/releases/download/${version}/myip_${your_os} -O myip
$ chmod +x ./myipkitsuyui/homebrew-myip is available.
$ brew tap kitsuyui/homebrew-myip
$ brew install myip$ go mod download
$ go build ./...This project uses lefthook to run the same checks as CI locally.
$ lefthook install- pre-commit: runs
go vet ./...to catch issues before each commit. - pre-push: runs
go vet ./...andgo test ./...before each push.
CI still runs the full suite on every pull request and push to main — the hooks bring that feedback earlier, to your local machine.
The 3-Clause BSD License. See also LICENSE file.
