- To find your local IP address from the CMD prompt, just type “ipconfig” in the command prompt. It will be listed as “IPv4 Address”.
- To find your public (external) IP address from a command prompt, type “curl ifconfig.me” on Windows 10 or 11.
As with most things in Windows, there are dozens of ways to get things done. So today we are going to show you several different techniques to find your public or private IP address using Command Prompt.
Why get your IP address from the command line when you can easily look it up in the GUI in Windows 10 or Windows 11? If you’re an old-school geek, using the command line is natural, so you might find it easier to type in a quick command rather than clicking through a whole bunch of settings. But the real reason is that you will probably automate it in a script and you just need to find the right command for the job.
Which IP do you want? Local (private) IP vs. external (public) IP
Get local (private) IP address from CMD (command prompt)
Get Public (External) IP Address from CMD (Command Prompt)
Get Powershell’s public IP address
Get the public IP address from the bash shell
Table of Contents
Which IP do you want? Local (private) IP vs. external (public) IP
Before we show you how to find your IP address, we need to talk about the difference between public and private IP addresses.
Every network you connect to has an associated IP address. If your computer is connected via both WiFi and Ethernet, both adapters have their own IP addresses and your local TCP/IP routing table is responsible for figuring out which one is used for which requests. Most of the time, however, you’re only connected to your Wi-Fi router, so your local computer that connects to your local network has a single IP address.
However, your Internet router is always connected to two separate networks: your local (private) network in your home and your ISP’s external (public) network. The router translates your computer’s request using NAT (Network Address Translation) so everything on your network can share a single public IP address.
When your Windows PC, iPhone, or Raspberry Pi connects to the internet from your house, the server they connect to sees them as the same IP address: the external (public) IP on your router.
Get local (private) IP address from CMD (command prompt)
To find your local or home IP address using Command Prompt in any version of Windows, simply open the Start menu, search for Command Prompt, open it, and type the following command:
ipconfig
Windows prints out a lot of details, but the line you’re looking for is the one that says “IPv4 Address,” which shows your local/private IP address for the adapter that’s connected to your Wi-Fi or Ethernet network connected is.
Some people have more than one adapter in the list, and if you’ve installed virtual machine software or WSL, you might see a bunch of extra stuff, so you’ll need to look for the adapter that’s connected to the network you’re using . Try to find the address for again.
Remember that this is your private IP address, not the public address that websites are seeing your traffic from. For your public IP address, read on.
Get Public (External) IP Address from CMD (Command Prompt)
There are many different ways to find your public/external IP address from Command Prompt, but perhaps the simplest is to simply enter the following command (assuming you already have Command Prompt open from the Start menu).
curl ifconfig.me
This command will immediately print your current public IP address right on the command line. It works with the curl command to download the contents of ifconfig.me, a very simple website someone set up to give out nothing but your public IP address. If you paste that domain name into your browser, you’ll see the same thing.
It’s worth noting that Windows 10 and 11 have the curl command built right in, but if you’re using an earlier version of Windows, you’ll probably need to download a copy of it curl for Windows. Curl should work within the normal Windows CMD prompt, but you can also use it within the Bash shell in Windows 10 or 11.
There are also a number of alternative methods to get your public IP address from Command Prompt and we’ll include those for completeness – and just in case the first one doesn’t work anymore! Here are a few:
curl myexternalip.com/raw
curl ipecho.net/plain
curl ifcfg.me
curl icanhazip.com
The last one oddly contains an extra line break that might not work very well if you’re using this in a script.
Perhaps my favorite method uses OpenDNS and the reliable nslookup command that has been present in every version of Windows for ages:
nslookup myip.opendns.com. resolver1.opendns.com

Now that you’ve had a blast reading about how to do all of this from the command prompt, I should probably point out that you can also just type “what’s my ip” into Google and it will tell you. But it’s just not that much fun that way.
Want to get more complicated? Did you know that you can actually change your IP address using Command Prompt? You can also edit the Windows registry, lock your PC, change a password, start Excel or Word, map network drives, shut down your PC, uninstall programs, compare files, find files, find your Windows product key, and even use all sorts of keyboard shortcuts from the old-school Windows command prompt.
Get Powershell’s public IP address
If you’re ready to have some serious fun, here’s how to find your public IP address using a more powerful PowerShell prompt (or script). Just type this into your PowerShell terminal:
(Invoke-WebRequest -UseBasicParsing -URI ifconfig.me ).Content
It immediately returns your IP address, just like all the other examples above. You can also split it into multiple lines when using it in a script:
$myip = Invoke-WebRequest -UseBasicParsing -URI ifconfig.me $myip.Content
This will create the $myip
variable and put the content of the request into it, and then you can use $myip.Content
to spit out the value or use it elsewhere in a script if needed. You can replace the ifconfig.me site with any of the other examples we showed you earlier, just in case that site breaks at some point in the future.
Get the public IP address from the bash shell
If you use the Bash shell within Windows, you’ll probably be glad to know that getting your public IP address is just as easy as using the command prompt. Just enter the following command:
curl ifconfig.me
It should work the same as the command in the regular CMD prompt, but you can do so much more with the bash shell than you can with the command prompt.
Ready to Find More IP Address Information? You can find your IP address using the GUI in Windows 10 or Windows 11, or look up the IP of your iPhone, Roku, printer, Wi-Fi router, or other device. Once you’re an expert, you can see what’s listening on TCP/IP ports and set up static IP routes.
This article was previously published on Source link