Windows command to display all IP addresses

I know there is a single line of a command and its arguments that can help display all computer IP addresses (those that are being used) on a LAN, and my computer is also a client, as one of those displayed, but I forgot. What is it?


Solution 1:

You could do the arp -a command to show all ARP entries in the table about computers on your network.

Source

Solution 2:

Not everything with an IP address is a computer - I found none of these suggestions returned all active IP addresses - in fact most returned very few. My home network has a combination of wired and wireless devices and two routers, mobile phones, TV, PVR, Apple AirPort and probably a few things I have forgotten. I used the following to scan all addresses on the 192.168.1.xxx subnet:

for /L %i in (0,1,255) do ping -n 1 -w 250 192.168.1.%i>>ipaddress.txt

The resulting file ipaddress.txt contains the ping results for all addresses and I looked for those with "Received = 1" - currently 16 addresses returned a result - I only have 4 computers in the house - and they were not all on.

Solution 3:

There is the net view /all command which will list all of the computer names that are connected to the same LAN.

From that you can retrieve the individual IP addresses using the nslookup <computer name> command or write a batch script to do it for you.

Here is an example batch I threw together to illustrate.

@echo off
setlocal EnableDelayedExpansion
set "xNext="
set "xComputer="
for /f %%A in ('net view /all') do (
    set "xComputer=%%~A"
    if "!xComputer:~0,2!"=="\\" for /f "tokens=2,* delims=. " %%X in ('nslookup %%A') do (
        if "!xNext!"=="1" (
            echo.!xComputer! = %%X.%%Y
            set "xNext=0"
        )
        if "!xComputer:~2!"=="%%~X" set "xNext=1"
    )
)
endlocal
pause