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?
36 Answers
I wrote a proper ip4 command out of similar frustration.
4You 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.
1I'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:
Find the name of the interface you want to know about
For me, it wasConfiguration for interface "Wi-Fi",
so for me the name isWi-Fi.
ReplaceWi-Fiin the command below with your interface namePowerShell:
netsh interface ip show address "Wi-Fi" ` | where { $_ -match "IP Address"} ` | %{ $_ -replace "^.*IP Address:\W*", ""}Output:
192.168.1.10Or, 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*//')
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"