Ping all addresses in network, windows

前端 未结 11 1518
庸人自扰
庸人自扰 2021-01-30 00:14

Is it possible in windows cmd line to check all of the network addresses (with ping or similar) to see which ones are taken/ have active devices:

ie. something that does

11条回答
  •  臣服心动
    2021-01-30 00:38

    @ECHO OFF
    
    IF "%SUBNET%"=="" SET SUBNET=10
    
    :ARGUMENTS
    ECHO SUBNET=%SUBNET%
    ECHO ARGUMENT %1 
    IF "%1"=="SUM" GOTO SUM
    IF "%1"=="SLOW" GOTO SLOW
    IF "%1"=="ARP" GOTO ARP
    IF "%1"=="FAST" GOTO FAST
    
    REM PRINT ARP TABLE BY DEFAULT
    :DEFAULT
    ARP -a
    GOTO END
    
    REM METHOD 1 ADDRESS AT A TIME
    :SLOW
    ECHO START SCAN
    ECHO %0 > ipaddresses.txt
    DATE /T >> ipaddresses.txt
    TIME /T >> ipaddresses.txt
    FOR /L %%i IN (1,1,254) DO ping -a -n 2 192.168.%SUBNET%.%%i | FIND /i "TTL="  >> ipaddresses.txt
    GOTO END
    
    REM METHOD 2 MULTITASKING ALL ADDRESS AT SAME TIME
    :FAST
    ECHO START FAST SCANNING 192.168.%SUBNET%.X
    set /a n=0
    :FASTLOOP
    set /a n+=1
    ECHO 192.168.%SUBNET%.%n%
    START CMD.exe /c call ipaddress.bat 192.168.%SUBNET%.%n% 
    IF %n% lss 254 GOTO FASTLOOP
    GOTO END
    
    :SUM
    ECHO START SUM
    ECHO %0 > ipaddresses.txt
    DATE /T >> ipaddresses.txt
    TIME /T >> ipaddresses.txt
    FOR /L %%i IN (1,1,254) DO TYPE ip192.168.%SUBNET%.%%i.txt | FIND /i "TTL=" >> ipaddresses.txt
    FOR /L %%i IN (1,1,254) DO DEL ip192.168.%SUBNET%.%%i.txt
    type ipaddresses.txt
    GOTO END
    
    :ARP
    ARP -a >> ipaddresses.txt
    type ipaddresses.txt
    GOTO END
    
    
    :END
    ECHO DONE WITH IP SCANNING
    ECHO OPTION "%0 SLOW" FOR SCANNING 1 AT A TIME
    ECHO OPTION "%0 SUM" FOR COMBINE ALL TO FILE
    ECHO OPTION "%0 ARP" FOR ADD ARP - IP LIST
    ECHO PARAMETER "SET SUBNET=X" FOR SUBNET
    ECHO.
    

提交回复
热议问题