Solved

Finding machines in a particular subnet

Posted on 2000-04-12
2
211 Views
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?
0
Comment
Question by:rsorrent
2 Comments
 
LVL 20

Expert Comment

by:tfewster
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")

possible.sh:
#!/usr/bin/ksh
i=1
j=1
while [ $i -lt 254 ]
do
  while [ $j -lt 254 ]
  do
    echo "a.b."$i"."$j >> /tmp/possible
    i=$(($i+1))
  done
  i=$(($i+1))
done

Now try to ping the possibles:
response.sh:
#!/usr/bin/ksh
for ADDRESS in `cat /tmp/possible`
do
  RESPONSE=""
  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
  else
     echo $ADDRESS >> /tmp/noresponse
  fi
done

/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 :(
0
 

Accepted Solution

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

http://www.insecure.org/nmap/index.html
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

830 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