How to Find Your IP Address From CMD (Command Prompt)

Configurare noua (How To)

Situatie

Like most things in Windows there are dozens of ways to get something done, so today we’re showing you multiple different techniques to find your public or private IP address from the command prompt.

Solutie

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. Each network that you’re connected to will have an IP address associated with it—if your computer is connected via Wi-Fi as well as Ethernet, both of the adapters will have their own IP addresses, and your local TCP/IP routing table is responsible for figuring out which one ends up getting used for which requests. Most of the time, though, you’re just connected to your Wi-Fi router, so your local computer connecting to your local network has a single IP address.

Your internet router, however, is always connected to two separate networks: your local (private) network in your house, and the external (public) network of your ISP. The router translates the request from your computer using NAT (Network Address Translation) to allow everything in your network to share a single public IP address. When your Windows PC, iPhone, or Raspberry Pi connect to the internet from your house, the server that they connect to will see 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 private IP address from the command prompt in any version of Windows, simply open up the Start Menu, search for the Command Prompt, open it up, and type the following command:ipconfig

Windows will output a lot of details, but the line you’re looking for is the one that says “IPv4 Address” which will display your local / private IP address for the adapter that is connected to your Wi-Fi or Ethernet network.

Some people will have more than one adapter in the list, and if you’ve got Virtual machine software installed or WSL you might see a lot of extra stuff, so you’ll need to check for the adapter that’s connected to the network you’re trying to find the address for. Keep in mind this is your private IP address, not the public address that websites will see your traffic coming from. For your public IP address, keep reading.

Get Public (External) IP address from CMD (Command Prompt)

To find your public / external IP address from the command prompt, you have a lot of different options, but perhaps the easiest one is to simply type the following command (assuming you’ve already opened Command Prompt from the Start Menu).

This command will instantly output your current public IP address right there on the command line. It works by using the curl command to download the contents of ifconfig.me, which is a very simple website that somebody set up to output nothing but your public IP address. If you plug 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 probably will need to download a copy of curl for Windows.

Curl should work from within the regular Windows CMD prompt, but you can also use it from within the Bash shell inside of Windows 10 or 11 as well. There are also a number of alternative methods for pulling up your public IP address from the command prompt, and we’ll include those for completeness—and just in case the first one stops working! Here are a few:

curl myexternalip.com/raw

curl ipecho.net/plain

curl ifcfg.me

curl icanhazip.com

That last one weirdly includes an extra line break, which might not work very well if you’re using this in a script. Perhaps my favorite method uses OpenDNS and the trusty nslookup command that’s been on every version of Windows since forever:  nslookup myip.opendns.com. resolver1.opendns.com

Tip solutie

Permanent

Voteaza

(3 din 4 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?