I made this tool as a convenient way to get my IPs, be they remote or local.
whatismyip --help | sed 's/\.exe//'
Work out what your IP Address is
Usage: whatismyip [OPTIONS]
Options:
-l, --only-local Only print IP addresses local to this machine
-w, --only-wan Only print IP addresses as seen by a remote service
-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
192.168.1.56
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
192.168.1.56
If you have an IPv4 address and an IPv6 address it'll list both
whatismyip
207.105.7.192
192.168.1.56
2001:0db8:85a3:0000:0000:8a2e:0370:7334
fe80::4
And if you have only an IPv6 address it'll list that
whatismyip
2001:0db8:85a3:0000:0000:8a2e:0370:7334
fe80::4
You can also force only v6 IPs
whatismyip -6
2001:0db8:85a3:0000:0000:8a2e:0370:7334
fe80::4
Or v4s
whatismyip -4
207.105.7.192
192.168.1.56
You can also get only IP Addresses local to your network interfaces
whatismyip -l
192.168.1.56
fe80::4
Or only the WAN ones
whatismyip -w
207.105.7.192
2001:0db8:85a3:0000:0000:8a2e:0370:7334
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.)
See the releases page we build for linux and mac (all x86_64), alternatively use brew
brew install PurpleBooth/repo/whatismyip
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