Friday, September 23, 2011

Basic TCL script for reachability testing


I have R1, R2, R3, and R4. I have a simple configuration where R2 is bridging R1 and R3, with a serial link to R4. I want to use a TCL ping script to quickly verify full reachability.


First, I'll visit each router and view the assigned IP addresses.

R1#show ip interface brief | exclude unassigned
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.1.13.1       YES manual up                    up      
Loopback0                  10.0.1.1        YES manual up                    up      
R1#


R2#show ip interface brief | exclude unassigned
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/1/0                10.1.24.2       YES manual up                    up      
BVI1                       10.1.13.2       YES manual up                    up      
Loopback0                  10.0.2.2        YES manual up                    up      
R2#


R3#show ip interface brief | exclude unassigned 
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.1.13.3       YES manual up                    up      
Loopback0                  10.0.3.3        YES manual up                    up      
R3#


R4#show ip interface brief | exclude unassigned
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/0                  10.1.24.4       YES manual up                    up 
Loopback0                  10.0.4.4        YES manual up                    up      
R4#

Now that I have all the IP addresses, I will add them to a notepad as a TCL script so that I can copy and paste into a router when I want to connect reachability.

tclsh
foreach ip {
10.1.13.1
10.0.1.1
10.1.24.2
10.1.13.2
10.0.2.2
10.1.13.3
10.0.3.3
10.1.24.4
10.0.4.4
} {ping $ip
}

I can keep this in notepad, and copy and paste it whenever I want to test reachability.

Here's the result of pasting it onto R1.

R1(tcl)#foreach ip {
+>(tcl)#10.1.13.1
+>(tcl)#10.0.1.1
+>(tcl)#10.1.24.2
+>(tcl)#10.1.13.2
+>(tcl)#10.0.2.2
+>(tcl)#10.1.13.3
+>(tcl)#10.0.3.3
+>(tcl)#10.1.24.4
+>(tcl)#10.0.4.4
+>(tcl)#} {ping $ip
+>(tcl)#}


Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.13.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/5 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.24.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.13.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.13.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.24.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
R1(tcl)#

1 comment: