How to get network ip address via windows command prompt? I know tat ipconfig /all shows ip configuration, but what about having just ipv4 adress?

  • Maybe this would do for you: netsh interface ip show address "Ethernet" | findstr "IP Address" . Substitute "Ethernet" with your main adapter name
    – Ashtray
    Feb 20 '14 at 6:57
  • what about a more general command? I mean getting all ipv addresses?
    – hpaknia
    Feb 20 '14 at 7:00
  • Just don't type the adapter's name and it'll output all the IP addresses
    – Ashtray
    Feb 20 '14 at 7:01

I wrote a proper ip4 command out of similar frustration.


(.exe is here)

  • if you use chocolatey you can just type choco install ip4
    – Treer
    Nov 10 '19 at 20:21
  • I downloaded it and my antivirus is flagging it.
    – jpruiz114
    Apr 6 '20 at 2:59
  • 1
    I reported the false flag to avast, and they claim to have fixed it
    – Treer
    Apr 13 '20 at 22:05
  • I will give it another try. Thanks for letting me know.
    – jpruiz114
    Apr 14 '20 at 23:04

You can view all the configured IP addresses using this command:

netsh interface ip show address | findstr "IP Address"

You can also add the adapter name to get IP address of a specific network interface.

netsh interface ip show address "Ethernet" | findstr "IP Address"

This should work in at least latest versions of Windows.


Another valid way is via WMIC:

wmic NICCONFIG WHERE IPEnabled=true GET IPAddress

This will show the IP address if there is one and the adapter that has it configured is enabled. Quite useful in many situations.

  • Getting the IP for the enabled adapter is a bonus! Thanks!
    – ariestav
    Jul 13 '20 at 19:29

I'm just building off of @Ashtray's answer,
but for me I needed the actual IP address only, so I'll share that here in case anyone else needs to similarly get just the address:

  1. Find the name of the interface you want to know about
    For me, it was Configuration for interface "Wi-Fi",
    so for me the name is Wi-Fi.
    Replace Wi-Fi in the command below with your interface name

  2. PowerShell:

    netsh interface ip show address "Wi-Fi" `
      | where { $_ -match "IP Address"} `
      | %{ $_ -replace "^.*IP Address:\W*", ""}


  3. Or, my edge case, executing command in WSL2:

    netsh.exe interface ip show address "Wi-Fi" \
       | grep 'IP Address' \
       | sed -r 's/^.*IP Address:\W*//'
    # e.g.
    export REACT_NATIVE_PACKAGER_HOSTNAME=$(netsh.exe interface ip show address "Wi-Fi" \
       | grep 'IP Address' \
       | sed -r 's/^.*IP Address:\W*//')
  • 1
    Thanks, I had the same edge case with with WSL2. I noticed that netsh.exe returns Windows-style newlines, while grep and sed expect Unix-style newlines. This causes problems explained in stackoverflow.com/a/35605692/923560 . I fixed this issue by adding dos2unix into the pipe. Here is an example on how to set $DISPLAY (e.g., also notice the adaption for German locale): export DISPLAY="$(netsh.exe interface ip show config name='Ethernet 2' | dos2unix | grep 'IP-Adresse' | sed -r 's/^.*IP-Adresse:\W*//'):0"
    – Abdull
    Oct 7 at 11:12

For those on Windows 10 with powershell, you can run:

[System.Net.Dns]::GetHostEntry([System.Net.Dns]::GetHostName()) | select AddressList

you can use this command

ipconfig | findstr /r /c:"IPv4"

it will display only IPv4 like this

IPv4 Address. . . . . . . . . . . : -> just example

or you can use also this

ipconfig /all | findstr /r /c:"IPv4"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.