Windows command that returns external IP

You could use a DNS request instead of HTTP request to find out your public IP:

C:\> nslookup myip.opendns.com. resolver1.opendns.com

It uses resolver1.opendns.com dns server to resolve the magical myip.opendns.com. hostname to your ip address. (Note: the trailing . on the lookup prevents search domains from being appended, which can yield incorrect results.)

Unix version:

$ dig +short myip.opendns.com @resolver1.opendns.com

grab your own copy of curlfrom http://curl.haxx.se/download.html and then just

curl "http://myexternalip.com/raw"

or use powershell:

$wc = new-object System.Net.WebClient
$wc.DownloadString("http://myexternalip.com/raw")

(disclaimer: http://myexternalip.com was created by me)


There is no built-in command to do this. Part of the problem is that when you are connected to the internet through a router, your network hardware is not directly connected to the internet, so your system isn't specifically assigned an IP. It's possible you might even have multiple external IPs in some cases if you are behind a reverse proxy, as many corporate networks are set up. Your best bet might be to create a script which queries whatismyip.org, or trying to find if one already exists.

(As a tip, whatismyip.org is preferable to most other solutions, since it just returns your IP as plain text - no superfluous text, links, images or other garbage. It would be much easier to use in a custom script than most of the other IP-detection sites.)