Finding machines in a particular subnet

Posted on 2000-04-12
Last Modified: 2013-12-06
I have a machine whose IP is a.b.c.d and wish to locate all other machines whose IP starts with a.b
Is there a command, either on NT or UNIX, that will do this for me recursively?
Question by:rsorrent
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 21

Expert Comment

ID: 2709868
You might be able to do it with snoop/tcpdump, but the following scripts should also do the job.

Build a list of valid addresses, excluding 0, 254 & 255 ("specials")
while [ $i -lt 254 ]
  while [ $j -lt 254 ]
    echo "a.b."$i"."$j >> /tmp/possible

Now try to ping the possibles:
for ADDRESS in `cat /tmp/possible`
  RESPONSE=`ping $ADDRESS | grep Reply`
  # NB, ping is OS dependent, e.g. in
  # HP-UX you must add the option
  # "-c count", or it will retry the
  # ping indefinitely
  if [ ! X$RESPONSE = X ] ; then
     echo $ADDRESS >> /tmp/responses
     echo $ADDRESS >> /tmp/noresponse

/tmp/responses will then be a list of all devices that are alive & have an IP address in that range, including Unix boxes, PCs, print servers etc. I guess the next step is to try to classify them...

/tmp/noresponse would be possible free IP addresses - assuming the device isn't switched off :(

Accepted Solution

sgoldgaber earned 200 total points
ID: 2710392
NMAP is a tool that can do what you want and much much much more:

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Restore XenServer VM with only dd image of LVM snapshot 3 265
AIX    Volume group Auto ON/OFF question 2 146
Virtualizing TAPE on dual VIOS 3 122
auto mounter on hp-ux 2 63
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question