TCL Ping Script

Rashmi Bhardwaj | Blog,Config & Troubleshoot
Advertisements

Network Administrator need to perform a lot of repetitive activities in network like ping multiple IPs to check their availability. These activities are time consuming and tiring too.

Good news!!

This all can be done at one go.

Advertisements

TCL Ping Script Is The Answer

As from Cisco IOS 12.2(25), TCL scripting has been made part of Cisco IOS. All one needs is the basics – To access the tcl command line in Cisco router issue the “tclsh” command. For the TCL ping script just modify the IP addresses what is shown below and it should be good.

Note: in below case, we are trying to ping 5 IP addresses.

foreach address {
1.1.1.1
2.2.2.2
3.3.3.3
4.4.4.4
5.5.5.5
} { puts [ exec “ping $address” ] }

The word “address” here is just a variable, you can substitute this with anything you want. Now lets try applying this to the Cisco router.

R1(tcl)#foreach address {
+>(tcl)#1.1.1.1
+>(tcl)#2.2.2.2
+>(tcl)#3.3.3.3
+>(tcl)#4.4.4.4
+>(tcl)#5.5.5.5
+>(tcl)#} { puts [ exec “ping $address” ]}Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/66/76 msType escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 64/64/68 msType escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/62/92 msType escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/55/64 ms

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/62/92 ms

That’s it!!!

Isn’t this simple and helpful ? In fact many CCIE candidates also use this script to save on time.

One can try this on GNS3 or dynamips lab and test the output. All the best !!!

Continue Reading:

Difference between IP Address and Port Number

CISCO IOS/XR AND JUNOS COMMAND REFERENCE

ABOUT THE AUTHOR


Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart