/usr/share/whereami/actions/findnet is in whereami 0.3.34-0.4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #!/bin/sh
#
# Script to assist in locating us on a particular network by confirming
# that we manage to hit a specified host with a quick 'ping'. We actually
# use 'fping' because it's waaay quicker.
#
# Written by Andrew McMillan <andrew@mcmillan.net.nz>, 10th December 1999
#
# $1 is the IP we are trying to find
# $2 is the IP number we should use on that subnet
#
mynet=`echo $1 | cut -d'.' -f1-3`
myip=$mynet.$2
ifconfig eth0 $myip >/dev/null 2>&1
# Note that the timeout on fping is set very low (30 mS - -t30) so that
# the host will need to be close for this to work. Most LANs will
# get a response in well under 30mS, but we kind of insist because
# we're only gonna retry once... (-r1).
#
if (fping -a -b12 -B1.2 -i5 -r1 -t30 $1) ; then
# echo "found $1"
# Leave the interface running in this case
RESULT=0
else
# echo "Not found"
RESULT=1
# Downing the interface might seem a good idea, but it makes our next
# attempt much slower. Better to down it after all attempts have failed.
# ifconfig eth0 down
ifconfig eth0 0.0.0.0 >/dev/null 2>&1
fi
exit $RESULT
|