tonybaldwin | blog

non compos mentis

Find IPs – a script to find all nodes on the LAN

with one comment

This will find all computers on the local area network:

#!/bin/bash

# find all nodes on this intranet

# create report file with date
fd=$(date +%m%d%y%H%M%S)
echo -e "IP$fd\nReport of IP addresses on this intranet, test started at \n$(date)\n\nThe following IP addresses were found:" > IP$fd.txt
echo -e " Okay. Mind you, this could take a couple of minutes.\nI'll be scanning all 254 possibilities between 192.168.1.1 and 192.168.1.254\nI will ring the system bell when I am done.\nHere we go..."
for i in 192.168.1.{1..254}
do
echo "scanning ... ... ..."
if ping -c1 -w1 $i &>/dev/null
then
echo -e "AHA! Got one! ---- $i is up!"
echo -e $i >> IP$fd.txt
fi
done
echo -e "That's all I got.\Test completed at\n$(date)\n" >> IP$fd.txt
echo -e \\a
echo -e "Your report is IP$fd.txt, and this is what it says:\n"
cat IP$fd.txt
exit

Starting looks like this:

finding IP address on the LAN

finding IP address on the LAN

In the end, it gives you a report that looks like this:

IP022211114605
Report of IP addresses on this intranet, test started at
Tue Feb 22 11:46:05 EST 2011
The following IP addresses were found:
192.168.1.1
192.168.1.100
192.168.1.101

That’s all I got.
Test completed at
Tue Feb 22 11:49:35 EST 2011

Like this:

FindIPS output

IP addresses found!

chmod that baby, pop her in ~/bin.
done.

public wiki page for this script

./tony

Advertisements

Written by tonybaldwin

February 22, 2011 at 10:00 am

One Response

Subscribe to comments with RSS.

  1. Of course, you could just pull up your router admin interface in a browser, but, where's the fun in that?

    tonybaldwin

    February 22, 2011 at 10:33 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: