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 or Finding your public IP from the command line is just as easy. Simply enter the following command into a command prompt window:


This command will resolve the name using the dns server If you try to resolve using any other name server, you will find it doesn't resolve. When you query it using, 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:

Post new comment