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?

3

6 Answers

I wrote a proper ip4 command out of similar frustration.

ip4

(.exe is here)

4

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.

1

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*", ""} 

    Output: 192.168.1.10

  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

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. . . . . . . . . . . : 169.168.81.1 -> just example

or you can use also this

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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