lunes, 27 de agosto de 2012

TCL: El clasico script de TCL para hacer ping

Un script TCL muy majete para lanzar desde un único router pings secuenciales a una lista de IP. Es considerado un clásico ya que para prepararte el examen del CCIE práctico lo usarás hasta la saciedad para comprobar que el routing funciona correctamente, especialmente después de redistribuciones.

Ejecución:

tclsh <---entramos en TCL

foreach address {
x.x.x.x
x.x.x.x
x.x.x.x
x.x.x.x} { ping $address
}<---se ejecutan los pings

tclquit <--- de lo contrario seguimos en TCL

Un ejemplo con un lab casero:

Rack05R1#tclsh
Rack05R1(tcl)#foreach address {
+>5.5.1.1
+>5.5.2.2
+>5.5.3.3
+>5.5.4.4
+>5.5.5.5
+>5.5.6.6
+>5.5.7.7
+>5.5.8.8
+>5.5.9.9
+>5.5.10.10
+>} { ping $address re 5
+>}

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.1.1, 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 5.5.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/20/32 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/14/36 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/9/12 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 = 4/5/8 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.6.6, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.7.7, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/6/12 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.8.8, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/7/16 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.9.9, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/8/16 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.10.10, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/9/12 ms

Rack05R1(tcl)#tclquit
Rack05R1#

Si habéis estado atentos habreis visto que todos respondían excepto el 5.5.6.6 :) .

Moraleja:

Ten preparado tu script de TCL para hacer ping a todo de manera sucesiva, para después de la intervención tan solo hacer un copy paste.


No hay comentarios:

Publicar un comentario