Ping Sweeps to test for packet loss on both router and host ends.

Answered Question

Does anyone know of a simple DOS batch mode or Linux script to ping a specified set of subnets with large numbers of pings? Purpose is to look for link problems not normally detected on the network-side equipment.

Correct Answer by Joe Clarke about 9 years 3 months ago

Something like this would work. This script will ping every address from .1 to .254 on each of the specified subnets. It will send one ping packet to each host:


## BEGIN script

proc pingSweep { } {

set subnet "10.0"

set octets [list 1 2 3 4 5 10 11 12 13 14 15 16 17 18 19 20]

for { set i 0 } { $i < [llength $octets] } { incr i } {

for { set j 1 } { $j < 255 } { incr j } {

set addr "${subnet}.[lindex $octets $i].${j}"

ping $addr repeat 1

}

}

}


pingSweep

## END script


Router#tclsh flash:pingSweep.tcl


This assumes you save this script into the router's flash as pingSweep.tcl. You could also type all of this in once you enter tclsh in IOS.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 4.7 (4 ratings)
Loading.
umedryk Mon, 01/14/2008 - 09:48
User Badges:
  • Bronze, 100 points or more

The following example will ping the ip address and will send 10 packets. Like wise specify the ip addresses that needs to be pinged

Router1#tclsh

Router1(tcl)#foreach i {

10.10.10.6

} { ping $i repeat 10 }


Correct Answer
Joe Clarke Mon, 01/14/2008 - 23:03
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Something like this would work. This script will ping every address from .1 to .254 on each of the specified subnets. It will send one ping packet to each host:


## BEGIN script

proc pingSweep { } {

set subnet "10.0"

set octets [list 1 2 3 4 5 10 11 12 13 14 15 16 17 18 19 20]

for { set i 0 } { $i < [llength $octets] } { incr i } {

for { set j 1 } { $j < 255 } { incr j } {

set addr "${subnet}.[lindex $octets $i].${j}"

ping $addr repeat 1

}

}

}


pingSweep

## END script


Router#tclsh flash:pingSweep.tcl


This assumes you save this script into the router's flash as pingSweep.tcl. You could also type all of this in once you enter tclsh in IOS.

Actions

This Discussion