How to get network ip address via windows command prompt?

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?


Solution 1:

I wrote a proper ip4 command out of similar frustration.

ip4

(.exe is here)

Solution 2:

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.

Solution 3:

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.

Solution 4:

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*//')