TCLSH and Macro Ping Test on Cisco Routers and Switches

When you are studying for CCIE R&S you will have to check connectivity every now and then. It’s a good idea to use ping to check if you can reach all IP addresses of the routers and switches in your network. If you have many devices and many IP addresses it will take too much time to ping each IP address manually.

Luckily you can use TCLSH (Tool Control Language) on your Cisco routers and devices, a scripting language that is used a lot by Cisco and one of the things it can do is ping IP addresses for us.

First you should check the active IP addresses on your device using the following command:

Router#show ip alias
Address Type             IP Address      Port
Interface                192.168.12.1 
Interface                192.168.13.1 
Interface                192.168.1.1

The show ip alias command will show you all active IP addresses on your device.  You can also use show ip interface brief | exclude unassigned to see all IP addresses of active interfaces:


Router#show ip interface brief | exclude unassigned
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.12.1     YES manual up                    up      
Serial0/0.1                192.168.13.1     YES manual up                    up      
Loopback0                  192.168.1.1      YES manual up                    up 

Copy and paste these to notepad…do this for all your routers and switches. Now we can use TCLSH to automatically ping all these IP addresses, this is how it works:

Router#tclsh
Router(tcl)#foreach address {
+>1.1.1.1
+>2.2.2.2
+>3.3.3.3
+>150.1.4.4
+>} { ping $address repeat 3 size 1500 }

Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/8/12 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/4/4 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 150.1.4.4, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 1/4/8 ms
Router(tcl)#tclquit

The script above will ping all my IP addresses 3 times and set the packet size to 1500 bytes.  Something you should remember is that you need to type tclquit to exit TCLSH scripting.

You can use TCLSH on routers and most switches. In case your switch doesn’t support TCLSH you can also create a macro that does a similar job. Here’s how to do it:

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You've Ever Spent on Your Cisco Career!
  • Full Access to our 651 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

568 Sign Ups in the last 30 days

satisfaction-guaranteed
100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.
No Questions Asked!

Forum Replies

  1. very useful… Thanks Rene !!

Ask a question or join the discussion by visiting our Community Forum