Solved

Finding machines in a particular subnet

Posted on 2000-04-12
2
200 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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
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…
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now