CISCO STUDENT GUIDE LAB 1 BSCI . TCL SCRIPTING
Saturday, September 13, 2008
Sight of relief ..
Today again after two horrible waste of days was finally on track... i started with cisco student lab guide and started the all new first step that is the TCL SCRIPT to ping all the interfaces .. here is the overview .
The Following is the toplogy
A SIMPLE DEMONSTRATION
in order to ping all of the interfaces at once ... you can use the tcl script and ping them
let us say you router is r0 and you want to ping 4 ip addresses(1.0.0.1 1.0.0.2 1.0.0.3 1.0.0.4) at a time
R0#tclsh
R0(tcl)# foreach address {
+>(tcl)#1.0.0.1
+>(tcl)# 1.0.0.2
+>(tcl)# 1.0.0.3
+>(tcl)# 1.0.0.4
+>(tcl)# } {
+>(tcl)# ping $address
+>(tcl)#}
you can ping as many addresses you have at one shot ...
the simplest thing to do is to write down in a note pad and copy paste in router ...
i advice the users who are using and seeing this for the first time to do it by hand in router to feel and see how prompts change ...
the two router configs will be pasted after this ,, i will list out the ip address first to use it in tcl script
1.0.0.1
1.0.0.2
2.0.0.1
2.0.0.2
3.0.0.1
3.0.0.2
4.0.0.1
4.0.0.2
5.0.0.1
5.0.0.2
6.0.0.1
6.0.0.2
7.0.0.1
7.0.0.2
as you might have imagine i need to change the prompt and ping 14 times which is not easy and time wasting ..
so this how script goes ...
open a note pad
tclsh
foreach address {
2.0.0.1
2.0.0.2
3.0.0.1
3.0.0.2
4.0.0.1
4.0.0.2
5.0.0.1
5.0.0.2
6.0.0.1
6.0.0.2
7.0.0.1
7.0.0.2
} {
ping $address
}
now at router prompt just copy the things in note pad and paste it into the router .. the following result if everthing done correctly should be appearing or ping wont be successful at the interfaces misconfigured
this is my output when executed on r1..
[code]r1(tcl)#tclsh
r1(tcl)#foreach address {
+>(tcl)#2.0.0.1
+>(tcl)#2.0.0.2
+>(tcl)#3.0.0.1
+>(tcl)#3.0.0.2
+>(tcl)#4.0.0.1
+>(tcl)#4.0.0.2
+>(tcl)#5.0.0.1
+>(tcl)#5.0.0.2
+>(tcl)#6.0.0.1
+>(tcl)#6.0.0.2
+>(tcl)#7.0.0.1
+>(tcl)#7.0.0.2
+>(tcl)#} {
+>(tcl)#ping $address
+>(tcl)#}
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/52/112 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/69/140 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/108/284 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/49/104 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/48/116 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/99/200 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 6.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/53/144 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 6.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/66/196 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 7.0.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/88/160 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 7.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/58/172 ms
r1(tcl)#
so this is the power of the script ... now to try my configs
directly open a router and paste my router 1 and router 2 configs and dont forget to manually reup the interfaces as they are in shutdown mode
CONFIG FOR R1
interface FastEthernet0/0
ip address 2.0.0.2 255.255.255.252
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 3.0.0.2 255.255.255.252
duplex auto
speed auto
!
interface Serial1/0
ip address 4.0.0.2 255.255.255.252
serial restart-delay 0
!
interface Serial1/1
ip address 5.0.0.2 255.255.255.252
serial restart-delay 0
!
interface Serial1/2
ip address 6.0.0.2 255.255.255.252
serial restart-delay 0
!
interface Serial1/3
ip address 7.0.0.2 255.255.255.252
serial restart-delay 0
!
ip http server
!
!
!
!
control-plane
!
!
line con 0
logging synchronous
line aux 0
line vty 0 4
!
!
end
CONFIG FOR R0
[code]interface FastEthernet0/0
ip address 2.0.0.1 255.255.255.252
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 3.0.0.1 255.255.255.252
duplex auto
speed auto
!
interface Serial1/0
ip address 4.0.0.1 255.255.255.252
serial restart-delay 0
!
interface Serial1/1
ip address 5.0.0.1 255.255.255.252
serial restart-delay 0
!
interface Serial1/2
ip address 6.0.0.1 255.255.255.252
serial restart-delay 0
!
interface Serial1/3
ip address 7.0.0.1 255.255.255.252
serial restart-delay 0
!
ip http server
!
!
!
!
control-plane
!
!
line con 0
logging synchronous
line aux 0
line vty 0 4
!
!
end
TCL NOTEPAD
tclsh
foreach address {
2.0.0.1
2.0.0.2
3.0.0.1
3.0.0.2
4.0.0.1
4.0.0.2
5.0.0.1
5.0.0.2
6.0.0.1
6.0.0.2
7.0.0.1
7.0.0.2
} {
ping $address
}
this is the reference from cisco website and number . tcl is valid from 12.3 ios and surprisingly i couldnt find it in 12.4 13b of 3660 so i executed on 3775
hxxp://www.cisco.com/web/about/security/intelligence/securetcl.html
regards
Rakesh