#!/bin/bash #Copyright 2003 William Stearns if [ -z "$4" ] || [ -n "$5" ]; then #Usage echo $0: scan all or part of a class C for rogue routers. >&2 echo Usage: >&2 echo $0 Subnet startIP EndIP MonitorIP >&2 echo Example: >&2 echo $0 17.18.19 1 254 99.99.99.99 >&2 echo MonitorIP should have the following running to collect output: echo tcpdump -qtnX \'icmp[0]=8\' >&2 exit 1 fi Subnet=$1 StartIP=$2 EndIP=$3 Monitor=$4 for IP in `seq $StartIP $EndIP` ; do echo Probing $IP sudo route add -host $Monitor gw $Subnet.$IP case $IP in [0-9]) ping -c 3 -w 4 -p 000$IP $Monitor >/dev/null 2>/dev/null ;; [0-9][0-9]) ping -c 3 -w 4 -p 00$IP $Monitor >/dev/null 2>/dev/null ;; *) ping -c 3 -w 4 -p 0$IP $Monitor >/dev/null 2>/dev/null ;; esac sudo route del -host $Monitor gw $Subnet.$IP sleep 5 done