HomeTechnologyNewsHow to find your IP address from CMD (Command Prompt)

How to find your IP address from CMD (Command Prompt)

- Advertisement -
- Advertisement -
- Advertisement -
- Advertisement -

[ad_1]

  1. To find your local IP address from the CMD prompt, simply type “ipconfig” at the prompt. It will appear as “IPv4 Address”.
  2. To find your public (external) IP address from a command prompt, type “curl ifconfig.me” in Windows 10 or 11.

Like most things in Windows, there are dozens of ways to do something, so today we’re going to show you multiple different techniques for finding your public or private IP address from a command prompt.

Why would you want to 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 kind of geek, using the command line to get things done comes naturally, so you might find it easier to type a quick command instead of clicking through a bunch of settings. The real reason though is that you’ll probably automate it in a script, and you just need to figure out the right command for the job.

What 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 you are connected to will have an associated IP address; if your computer is connected via Wi-Fi and Ethernet, both adapters will have their own IP addresses and local TCP/IP routing table. it is responsible for figuring out which one ends up being used for which requests. However, most of the time, you are only connected to your Wi-Fi router, so your local computer connecting to your local network has only one IP address.

However, your Internet router is always connected to two separate networks: your local (private) network at home and the external (public) network of your ISP. The router translates your computer’s request using NAT (Network Address Translation) to allow everything on your network to share a single public IP address.

When your Windows PC, iPhone, or Raspberry Pi connect to the Internet from home, the server 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 on any version of Windows, simply open the Start menu, search for command prompt, open it, and type the following command:

ipconfig

Windows will output a lot of detail, 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’s connected to your Wi-Fi or Ethernet network.

ipconfig for local IP address

Some people will have more than one adapter listed, and if you have WSL or virtual machine software installed, you may see a lot of extra stuff, so you’ll need to check which adapter is connected to the network. I’m trying to find the address of.

Keep in mind that this is your private IP address, not the public address that websites will see your traffic coming from. For your public IP address, read on.

Get public (external) IP address from CMD (Command Prompt)

To find your public/external IP address from the command prompt, you have many different options, but perhaps the easiest is to simply type the following command (assuming you’ve already opened command prompt from the Start menu):

curl ifconfig.me

This command will instantly generate 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 someone set up to generate nothing more than their public IP address. If you plug in that domain name in your browser, you’ll see the same thing.

It’s worth noting that Windows 10 and 11 have the curl command built in, but if you’re using an older version of Windows, you’ll probably need to download a copy of curl for Windows. Curl should work from the normal Windows CMD prompt, but you can also use it from the Bash shell within Windows 10 or 11.

There are also a number of workaround methods to get your public IP address from the command prompt, and we’ll include them for completeness, and 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

The latter strangely includes an extra newline, which might not work very well if you’re using this in a script.

Perhaps my favorite method uses OpenDNS and the trusted nslookup command that has been in every version of Windows forever:

nslookup myip.opendns.com. resolver1.opendns.com

nslookup for IP address

Now that you’ve had a lot of fun reading about how to do all of this from a command prompt, I should probably point out that you can also type “what’s my ip” into Google and it will tell you. But it’s not as fun that way.

Do you want to be more complicated? Did you know that you can change your IP address from a 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, locate your Windows product key, and even use everything. Kind of keyboard shortcuts from the old-school Windows command prompt.

Get public IP address from Powershell

If you’re ready to have some real fun, here’s how to find your public IP address from a more powerful PowerShell prompt (or script, for that matter). Just type this in your PowerShell terminal:

(Invoke-WebRequest -UseBasicParsing -URI ifconfig.me ).Content

It will instantly return your IP address just like all the other examples above. You can also split it across multiple lines if you’re going to use it in a script:

$myip = Invoke-WebRequest -UseBasicParsing -URI ifconfig.me
$myip.Content

This will create the $myip variable and put the request content in 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 above, in case that site goes down at some point in the future.

Get the public IP address of the bash shell

If you’re using the Bash shell from Windows, you’ll probably be happy to know that getting your public IP address is as simple as from a command prompt. Just type the following command:

curl ifconfig.me

It should work exactly the same way the command did at the regular CMD prompt, but you can do a lot more with the Bash shell than you can with the command prompt.

Ready to find out more about IP addresses? You can find your IP address using the GUI in Windows 10 or Windows 11, or find the IP of your iPhone, Roku, printer, Wi-Fi router, or any other device. Once you’re an expert, you can move on to seeing what you’re listening on the TCP/IP ports and configuring static IP routes.

[ad_2]

- Advertisement -
- Advertisement -
Must Read
- Advertisement -
Related News
- Advertisement -