Quick Method for Determining IP Number Status

Posted on June 4th, 2008 by DJ Roberts at Galil
Posted in Software |

When working with a small network, it is important to maintain a record of each node’s IP address and function. With Galil Controllers, this task is easy, as the GalilTools connections window will automatically detect Galil devices on the network:

GalilTools Connections Dialog Finds Galil Controllers

For computers and other non-Galil devices, finding which nodes exist, their IP numbers, and their purpose can be more challenging. The first step in defining a network topography is to determine which IP numbers are assigned to hardware. One easy method is to use the following batch file.

This script will scan through a type C subnet (255.255.255.0) to detect devices on the net. Hardware must be pingable for this script to function.

The file script will create a file, “valid.txt” containing all IP addresses which returned pings.

Example Output:

C:\temp>findPing.bat 192.168.1.
0
1
2
3
4
5
6
7
8
9
10
*** 192.168.1.10 Ping Returned! ***
11
*** 192.168.1.11 Ping Returned! ***
12
*** 192.168.1.12 Ping Returned! ***
13
14
*** 192.168.1.14 Ping Returned! ***

And so on…

Batch File Source:

@ECHO OFF
ECHO %DATE% > pings.txt
ECHO %TIME% >> pings.txt
ECHO Valid IPs: > valid.txt
IF “%1″ == “” goto :usage
SET byte=0
:loop
ECHO %byte%
ping %1%byte% -n 1 -w 100 >> pings.txt
IF %ERRORLEVEL% == 0 GOTO :GOOD
:continue
SET /A byte = %byte% + 1
IF %byte% == 256 goto :END
GOTO :loop

:GOOD
ECHO *** %1%byte% Ping Returned! ***
ECHO %1%byte% >> valid.txt
GOTO :continue

:usage
ECHO Ping Search. Search for devices in range with ping.
ECHO Assumes a subnet of 255.255.255.0.
ECHO.
ECHO Usage
ECHO %0 IPsubstring
ECHO Be sure that IPsubstring is actually in the subnet of your NIC card!
ECHO Don’t forget the trailing period
ECHO Example
ECHO %0 192.168.1.
:END
ECHO %TIME% >> pings.txt
ECHO.
type valid.txt
ECHO DONE

Post a Comment