martes, 5 de noviembre de 2013

El comando "do"


Este truco ya es viejo, pero aún en día veo gente que no lo sabe y termina escribiendo de mas:

¿Cuántas veces nos pasó al levantar un enlace nuevo y al instante queremos probarlo?. Lo habitual es que pase esto:
ero#conf t
Enter configuration commands, one per line. End with CNTL/Z.
ero(config)#interface g1/0
nero(config-if)#ip address 10.0.0.1 255.255.255.0
ero(config-if)#no shutdown
*Feb 16 17:51:19.643: %LINK-3-UPDOWN: Interface GigabitEthernet1/0, changed
e to up
ero(config-if)#ping 10.0.0.2
                      ^
% Invalid input detected at '^' marker.

El apuro nos nubla el cerebro y no podemos apretar Ctrl+Z para volver al modo privilegiado!!!.

Ni hablar de si estamos editando algún tipo de política de enrutamiento, access-list o cualquier cosa que sea un submodo de configuración:
ero(config)#route-map COSA-IMPORTANTE permit 156
ero(config-route-map)#match ip address prefix-list LISTA-PRIVADA 
ero(config-route-map)#set tag 65333
ero(config-route-map)#set ip next-hop ?
  A.B.C.D              IP address of next hop
  dynamic              application dynamically sets next hop
  peer-address         Use peer address (for BGP only)
  recursive            Recursive next-hop
  verify-availability  Verify if nexthop is reachable

¿Cual era el next-hop?... hay que sacarlo de la tabla de enrutamiento... pero... tengo que salir del modo de configuración del route-map... ver la tabla... y luego volver a entrar...
Pare de sufrir amigo!!
Para estos menesteres existe el comando DO:

ero(config-route-map)#do show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is 192.168.76.43 to network 0.0.0.0

C    192.168.76.0/24 is directly connected, FastEthernet0/0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.0.0.0 is directly connected, GigabitEthernet1/0
S*   0.0.0.0/0 [1/0] via 192.168.76.43
ero(config-route-map)#set ip next-hop 192.168.76.43ero(config-route-map)#endero#

Siempre que quieras ejecutar un comando estando en un modo de configuración antepone el comando do para que IOS lo ejecute igual.
ero(config-if)#ip address 10.0.0.1 255.255.255.0
ero(config-if)#no shutdown
*Feb 16 17:51:19.643: %LINK-3-UPDOWN: Interface GigabitEthernet1/0, changed
e to up
ero(config-if)#do ping 10.0.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/8/12 ms

ero(config)#cry keyring security
ero(conf-keyring)#do show ip interface brief
Interface                  IP-Address      OK? Method Status     Protocol
FastEthernet0/0            192.168.76.40   YES manual up            up
GigabitEthernet1/0         10.0.0.1        YES manual up            up
SSLVPN-VIF0                unassigned      NO  unset  up            up
Loopback0                  unassigned      YES unset  up            up

El único problema con esto es que no vas a poder autocompletar con la tecla [TAB] ni va tener la ayuda contextual con el ?.  Pero bueno, al fin y al cabo la felicidad nunca es completa.

No hay comentarios:

Publicar un comentario