How to Get Public External IP From Command Line - Windows

Printer-friendly versionPDF version
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

How can I get my Public external Gateway and Mask?

You would have to get that information from your ISP

Is it possible to execute the nslookup command and also pipe the results to a csv or txt file which will maintain a log of past IP addresses (preferably with a timestamp beside it)? This would allow one to track the WAN IP activity over time for a laptop.

Possibly, but I actually wrote a program specifically for this. It uses a Windows service to get your public IP an log it. The logs are stored in the Windows Event Viewer:

https://github.com/ingram1987/Public-IP-Logger

Post new comment