On Thursday 26 May 2011 17:24:05 Florian Philipp wrote: > Am 25.05.2011 21:45, schrieb Harry Putnam: > > There must be a number of people who post here that have had to do > > this problem. > > > > Discover the addresses of computers on a home network that have > > connected by way of DHCP. For example: Several wireless connections. > > > > I've used static IPS for around 10 yrs, always seemed handier for > > things like ssh between home lan computers. > > > > But recently started using DHCP for wireless connections. It must be > > such a popular method for some reason. > > > > But when you do it that way, and say want to VNC or ssh or the like to > > something connected by a dhcp serving WAP then how do you find the > > address? > > > > That is, besides something like accessing the WAP and checking the IPs > > connected to it. > > > > Is there some quick and sure way to discover any IPs on the home lan? > > > > Some kind of mapper tool? > > While I personally prefer a combined DHCP+DNS server like dnsmasq, you > can also take a look at the whole Zeroconf/MDNS/Avahi/Bonjour stack. > > I'm not really sure if you can configure common devices and Linux PCs to > use the DNS server for internet addresses and MDNS for local ones. In > theory, it should be possible since you can distinguish them (local > addresses should not be fully qualified _or_ have the domain .local). > > net-misc/mDNSResponder, sys-auth/nss-mdns and net-dns/avahi are probably > good starting points.
netdiscover seems to do exactly what the OP asked for, although I have used
arping and a couple of scripts I found on the net and modified them.
The first looks like this:
=============================
#!/usr/bin/env bash
quit_on_found=0
packet_count=2
subnet=""
verbose="-q"
usage()
{
cat << EOF
find_ip 1.0 Robin Wood ([email protected]) (www.digininja.org)
Find used and unused IPs on a network you don't haven an IP address on
usage: $0 options
OPTIONS:
-h Show this message
-c <packet count> The number of ping packets to send, default 2
-s <subnet> First 3 parts of the subnet to test, default
192.168.0
-q Quit when found first free address, default keep
going
-v Verbose
EOF
}
have_arping=`which arping`
if [[ "$have_arping" == "" ]]
then
cat << EOF
usage: $0 options
You must have arping installed and in the current path for this scanner to
work
EOF
exit 1
fi
while getopts ":hvs:qc:" flag
do
case $flag in
h)
usage
exit 1
;;
c)
packet_count=$OPTARG
;;
q)
quit_on_found=1
;;
s)
subnet=$OPTARG
;;
v)
verbose=""
;;
?)
usage
exit 1
;;
esac
done
if [[ "$subnet" == "" ]]
then
cat << EOF
usage: $0 options
You must provide a subnet
EOF
exit 1
fi
if [[ "$verbose" == "" ]]
then
if [[ $quit_on_found == 1 ]]
then
echo "Quiting when found a free address"
fi
echo "Testing subnet $subnet.0/24"
echo "Sending $packet_count packets per IP"
fi
for i in {1..254}
do
IP=$subnet.$i
arping $verbose -c $packet_count $IP
result=$?
if [[ $result == 0 ]]
then
echo "$IP Used"
else
echo "$IP Free"
if [[ $quit_on_found == 1 ]]
then
exit
fi
fi
done
=============================
Google for "find_ip.sh"
The other which I can't find at the moment prints out the MAC address of each
IP address that is in use. Alternatively, run the above script with the -v
option and then scroll back to look at the MAC addresses.
Of course, I was using this before I knew that netdiscover existed - thanks
for sharing!
--
Regards,
Mick
signature.asc
Description: This is a digitally signed message part.

