How to Get Public External IP From Command Line - Windows
If you are trying to find out what your public external IP address is, you typically go to a web site specifically for this purpose, such as ipchicken.com or whatsmyip.org. Finding your public IP from the command line is just as easy. Simply enter the following command into a command prompt window:
nslookup myip.opendns.com resolver1.opendns.com
This command will resolve the name myip.opendns.com using the dns server resolver1.opendns.com. If you try to resolve myip.opendns.com using any other name server, you will find it doesn't resolve. When you query it using resolver1.opendns.com, it will return the public IP that you sent the request from, which is your public IP. So thanks to OpenDNS for making this feature available to us!
This command will also work on Linux or Mac. For Linux, there is an even easier command to remember, see here