Wednesday, October 3, 2012

Cisco Shortcut Commands

I recently stumbled across a feature in IOS that I find very helpful. It is a way to add command aliases in your device. This will allow you to run lengthy commands with a short command of your choosing.

Not only is that extremely convenient, but the commands couldn't be simpler!

Here's the format:
alias <level> 'alias name' 'command '

To run a command use "exec" for the level. For example:
alias exec sr show run - This command would allow you to type "sr" as a substitution for "show run".

One word of caution. If you are studying for a certification I would strongly suggest you use full commands to help you remember them. After you land your sweet job make it easier and faster with these aliases.

Here's some suggestions:

Voice Router Commands:

  • alias exec scall show call active voice brief
  • alias exec sct show controller t1
  • alias exec scall show voice call summary
General Router Commands:
  • alias exec crs copy running-config startup-config
  • alias exec cdp show cdp neighbors
  • alias exec sib show ip interface brief
  • alias exec sir show ip route
  • alias exec sr show running-config
  • alias exec srb show running-config | begin
  • alias exec sri show running-config | include
  • alias exec sre show running-config | exclude
  • alias exec srint show running-config interface
I am sure you can think of a million more, but these were some of the most common commands I could think of. Feel free to post them up!


4 comments:

  1. TCL is built into IOS. there are tons of examples and even a cisco press book

    my favorite is This script that displays IP address, subnet mask and IP MTU size in a tabular format

    alias exec ipconfig tclsh flash:ipInterfaces.tcl

    ! add the belkow text to a file called ipInterfaces.tcl and upload to your FLASH:

    then simply type ipconfig
    ================
    # Copyright (c) 2007 NIL Data Communications
    # All rights reserved.
    #
    # by: Ivan Pepelnjak, NIL Data Communications
    # title: Display IP interface parameters in tabular format
    # name: ipInterfaces.tcl
    # desc: This script displays IP address, subnet mask and IP MTU size in a tabular format
    # history: Version 2. Fixed the IP address format issues (see ip netmask-format).
    #
    # ios config:
    #
    # * download the file into flash:ipInterfaces.tcl
    # * configure alias exec ipconfig tclsh flash:ipInterfaces.tcl
    #
    # invoke with ipconfig [active|configured|address]
    #

    proc printInterface {dataName} {
    upvar $dataName data
    global lineFormat paramActive paramConfig
    if {! [array exists data]} { return }
    if {$paramActive != 0} { if {! [string equal $data(IFSTAT) "up"]} { return } }
    if {$paramConfig != 0} { if {[string equal $data(IPADDR) "no address"]} { return } }

    puts [format $lineFormat $data(IFNAME) $data(IPADDR) $data(IPMTU) $data(IFSTAT)]
    }

    proc usage {} { puts {Syntax: ipconfig [active|configured|address]} }

    proc parseParams {} {
    global paramActive paramConfig paramAddress argv

    set paramActive 0
    set paramConfig 0
    set paramAddress 0

    foreach par $argv {
    switch $par {
    active { set paramActive 1 }
    configured { set paramConfig 1 }
    address { set paramAddress 1 }
    help { usage; return 1; }
    default { usage; return 1; }
    }
    }
    return 0;
    }

    if {[parseParams] == 1} {return}
    set lineFormat "%-20s %-20s %5s %s"
    puts [format $lineFormat {Interface} {IP Address} {MTU} {State}]
    puts "=============================================================="
    exec {terminal ip netmask-format bit-count}
    set cmdtext [exec {show ip interface}]
    ##set paramActive [string equal [lindex $argv 0] "active"]

    foreach line [split $cmdtext "\n"] {
    if {[regexp -nocase {^(\S+) is (.*), line protocol is (\S+)} $line ignore ifname ifstat iflstat]} {
    printInterface ifdata
    set ifdata(IFNAME) $ifname
    set ifdata(IPADDR) "no address"
    set ifdata(IPMTU) ""
    set ifdata(IFSTAT) $ifstat
    if {[string equal $ifstat "up"]} {
    if {![string equal $iflstat "up"]} { set ifdata(IFSTAT) "$ifstat/$iflstat" }
    }
    regsub -all {administratively} $ifdata(IFSTAT) "admin" ifdata(IFSTAT)
    } elseif {[regexp -nocase {internet address is ([0-9.]+/[0-9]+)} $line ignore ipaddr]} {
    set ifdata(IPADDR) $ipaddr
    } elseif {[regexp -nocase {Using address of (\S+)\s+\(([0-9.]+)\)} $line ignore ipif ipaddr]} {
    set ifdata(IPADDR) $ipif
    if {$paramAddress != 0} { set ifdata(IPADDR) "$ipaddr (U)" }
    } elseif {[regexp -nocase {MTU is ([0-9]+)} $line ignore ipmtu]} {
    set ifdata(IPMTU) $ipmtu
    }
    }
    if {[array exists ifdata]} { printInterface ifdata }
    exec {terminal no ip netmask-format bit-count}

    ReplyDelete
  2. that is a great TCL script

    ReplyDelete
  3. Thanks for sharing this shortcut commands.It is really useful.Keep sharing.
    ccna Training in Chennai

    ReplyDelete