Solved

Finding machines in a particular subnet

Posted on 2000-04-12
2
222 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
[X]
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
2 Comments
 
LVL 21

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

Industry Leaders: 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

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…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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…

691 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