Retrieve IP Addresses on Subnet
This batch file will gather a list of IP addresses in a chosen subnet on run and store them in the file ipaddresses.txt. It should be run as filename.bat 192.168.0
by providing the first 3 of the 4 octets in the IP address.
@ECHO OFF
REM Example usage "GetIPs 192.168.0"
:ARGUMENTS
SET SUBNET=%1
REM METHOD 1 ADDRESS AT A TIME
ECHO START SCAN of Subnet %SUBNET%
ECHO %0 > ipaddresses.txt
DATE /T >> ipaddresses.txt
TIME /T >> ipaddresses.txt
FOR /L %%i IN (1,1,254) DO (
echo Pinging %SUBNET%.%%i
ping %SUBNET%.%%i -a -w 200 -n 1 | FIND /i "TTL=" >> ipaddresses.txt
)
ECHO Done with IP Scanning
ECHO Getting ARP information
ARP -a >> ipaddresses.txt