CLI commands to find your public IP address.
> curl icanhazip.com 11.22.33.44 > echo $(curl -s https://api.ipify.org) 11.22.33.44 # echo is just to add \n to the end
# via OpenDNS > dig +short myip.opendns.com @resolver1.opendns.com 11.22.33.44 # via Google > dig TXT +short o-o.myaddr.l.google.com @ns1.google.com "11.22.33.44" # via Akamai > dig @ns1-1.akamaitech.net ANY whoami.akamai.net +short 11.22.33.44
Install the ISC dig and host tools.
# same as above, but nslookup for Windoze > nslookup myip.opendns.com resolver1.opendns.com Server: resolver1.opendns.com Address: 208.67.222.222 Non-authoritative answer: Name: myip.opendns.com Address: 11.22.33.44
(Invoke-WebRequest 'http://icanhazip.com/').Content
Which can be shortened to
(iwr 'http://icanhazip.com/').Content
Invoke-WebRequest is also aliased as curl so this is another way to get the same result.
curl icanhazip.com | Select-Object -ExpandProperty Content
You could sub http://api.ipify.org/ to get the same results.