Skip to content

PurpleBooth/whatismyip

Repository files navigation

What is my ip

Work out what your external ip is. This is done by querying the o-o.myaddr.l.google.com TXT record on the Google DNS servers (ns1.google.com, ns2.google.com, ns3.google.com, or ns4.google.com).

You can do the same thing yourself running using the dig tool:

dig TXT +short o-o.myaddr.l.google.com @ns1.google.com

I made this tool as a convenient way to do the same thing, including making multiple requests via only IPv4 and IPv6, so you can see both your IPv4 and IPv6 addresses.

Usage

whatismyip --help | sed 's/\.exe//'
Work out what your external ip is

Usage: whatismyip [OPTIONS]

Options:
  -4, --only-4   Only print IPv4 addresses
  -6, --only-6   Only print IPv6 addresses
  -r, --reverse  Print the reverse DNS entries for the IP addresses
  -h, --help     Print help
  -V, --version  Print version

When you run it you should get an IP back

whatismyip
207.105.7.192

It returns IPs and only IPs

whatismyip | grep -E '([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|(([a-f0-9:]+:+)+[a-f0-9]+)'
207.105.7.192

If you have an IPv4 address and an IPv6 address it'll list both

whatismyip
207.105.7.192
2001:0db8:85a3:0000:0000:8a2e:0370:7334

And if you have only an IPv6 address it'll list that

whatismyip
2001:0db8:85a3:0000:0000:8a2e:0370:7334

You can also force only v6 IPs

whatismyip -6
2001:0db8:85a3:0000:0000:8a2e:0370:7334

Or v4s

whatismyip -4
207.105.7.192

You can also reverse those IPs, which is handy for checking VPNs and similar where you want to identify your gateway exit point

whatismyip -r
207.105.7.192 (5898c708dfaf.dip0.t-ipconnect.de.)
2001:0db8:85a3:0000:0000:8a2e:0370:7334 (c06aa6b6af6c4ad5b46473d8d70bc068.dip0.t-ipconnect.de.)

Installing

See the releases page we build for linux and mac (all x86_64), alternatively use brew

brew install PurpleBooth/repo/whatismyip