Annotation of embedaddon/arping/extra/arping-scan-net.sh, revision 1.1.1.1
1.1 misho 1: #!/bin/sh
2: # arping-scan-net.sh
3: #
4: # Copyright (C) 2002 Thomas Habets <thomas@habets.pp.se>
5: #
6: # This library is free software; you can redistribute it and/or
7: # modify it under the terms of the GNU General Public
8: # License as published by the Free Software Foundation; either
9: # version 2 of the License, or (at your option) any later version.
10: #
11: # This library is distributed in the hope that it will be useful,
12: # but WITHOUT ANY WARRANTY; without even the implied warranty of
13: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: # General Public License for more details.
15: #
16: # You should have received a copy of the GNU General Public License along
17: # with this program; if not, write to the Free Software Foundation, Inc.,
18: # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19: #
20:
21: trap "exit 0" INT
22:
23: if [ "$1" = "" ]; then
24: echo
25: echo "Usage: $0 <mac address>"
26: echo ""
27: echo " Sorry, it's not more configurable than that, edit the source"
28: echo
29: exit 1
30: fi
31: TARGET_MAC="$1"
32:
33: # seq doesnt exist on some retarded boxen, comment out if your box is too
34: # stupid to have bc and/or tr
35: seq() { echo "for (i=$1; i<=$2; i++) i;" | bc | tr "\012" " "; }
36:
37: #
38: # first number after 'seq' is range start, second is range end
39: #
40: # default is [192-192].[168-168].[0-0].[0-255]
41: #
42: #
43: # I may put this functionality into ARPing one day if people seem to like it.
44: #
45: for a in $(seq 192 192); do
46: for b in $(seq 168 168); do
47: for c in $(seq 0 0); do
48: for d in $(seq 0 255); do
49: sh -c "arping -A -q -c 1 -T $a.$b.$c.$d $TARGET_MAC
50: if [ \$? = 0 ]; then
51: echo Got answer with address: $a.$b.$c.$d
52: fi" &
53: done
54: wait
55: done
56: done
57: done
58: #exit 1
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>