Skip to content

Determine your Internet-facing IP address and location from multiple sources.

License

Notifications You must be signed in to change notification settings

bengarrett/myip

Repository files navigation

MyIP Tetrad

goreleaser   Go Reference

MyIP Tetrad is a simple to use terminal tool to determine your Internet-facing IP address and location from four remote sources. Developed on Go, it's a portable self-contained binary with no dependencies.

It is an excellent tool for quickly determining if your machine or network is connected to the Internet or to see if a VPN is activated.

Downloads

Windows, macOS, Linux and more...

Packages

apk - Alpine package, deb - Debian package, rpm - Redhat package

# Alpine package
apk add myip.apk

# Debian package
dpkg -i myip.deb

# Redhat package
rpm -i myip.rpm

Usage

myip -help
# MyIP Usage:
#     myip [options]:
#
#     -h, --help       show this list of options
#     -f, --first      returns the first reported IP address and its location
#     -s, --simple     simple mode only displays the IP address
#     -t, --timeout    https request timeout in milliseconds (default: 5000 [5 seconds])
#     -v, --version    version and information for this program
myip
# (1/4) 93.184.216.34, Norwell, United States
# (2/4) 93.184.216.34, Norwell, United States
# (3/4) 93.184.216.34, Norwell, United States
# (4/4) 93.184.216.34, Norwell, United States
myip -first
# (1/1) 93.184.216.34, Norwell, United States
myip -simple
# 93.184.216.34
# 93.184.216.34
# 93.184.216.34
# 93.184.216.34
myip -simple -first
# 93.184.216.34
myip -timeout=900
# (1/4) 93.184.216.34, Norwell, United States
# ip4.seeip.org: timeout
# (3/4) 93.184.216.34, Norwell, United States
# api.ipify.org: timeout

Build

Go supports dozens of architectures and operating systems letting MyIP to be built for most platforms.

# clone this repo
git clone git@github.com:bengarrett/myip.git

# access the main.go
cd myip/cmd/myip

# target and build the app for the host system
go build

# target and build for Windows 7+ 32-bit
env GOOS=windows GOARCH=386 go build

# target and build for OpenBSD
env GOOS=openbsd GOARCH=amd64 go build

# target and build for Linux on MIPS CPUs
env GOOS=linux GOARCH=mips64 go build

MyIP uses the following online APIs.

The IP region data is from GeoLite2 created by MaxMind, available from maxmind.com.

I found Steve Azzopardi's excellent import "context" post useful for understanding context library in Go.