Solved

Finding machines in a particular subnet

Posted on 2000-04-12
2
202 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

930 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

13 Experts available now in Live!

Get 1:1 Help Now