Cisco CLI Tips.

by David Sudjiman ~ March 18th, 2008. Filed under: Cisco.

Shortcut them all

This is an old skool but just in case you don’t know it. You can use shorter command on your Cisco router or switch.

router#copy running-config startup-config
Destination filename [startup-config]?
Building configuration…
[OK]
router#copy run start
Destination filename [startup-config]?
Building configuration…
[OK]
router#wr
Building configuration…
[OK]

router#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            1.1.1.9         YES NVRAM  up                    up
Serial1/0                  unassigned      YES NVRAM  administratively down down
Serial1/1                  unassigned      YES NVRAM  administratively down down
Serial1/2                  unassigned      YES NVRAM  administratively down down
Serial1/3                  unassigned      YES NVRAM  administratively down down
Loopback0                  1.1.1.1         YES NVRAM  up                    up      

router#sh ip int br
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            1.1.1.9         YES NVRAM  up                    up
Serial1/0                  unassigned      YES NVRAM  administratively down down
Serial1/1                  unassigned      YES NVRAM  administratively down down
Serial1/2                  unassigned      YES NVRAM  administratively down down
Serial1/3                  unassigned      YES NVRAM  administratively down down
Loopback0                  1.1.1.1         YES NVRAM  up                    up

There are a lot more to try and bet you can find it yourself.

Get your CPU processes SORTED.

Checking your CPU usage. You know that to expect when you check your CPU processes. You will be presented with bunch of line of processes running on your CPU whilce you are actually needs to know what are the culprits that utilizing most of the CPU cycle. The idea is to get rid of the 0.00% 0.00% 0.00% lines and you will get what you want in less lines.

router#sh proc cpu | e 0.00%  0.00%  0.00%
CPU utilization for five seconds: 0%/0%; one minute: 1%; five minutes: 0%
 PID Runtime(ms)   Invoked      uSecs   5Sec   1Min   5Min TTY Process
   2          28        52        538  0.08%  0.00%  0.00%   0 Load Meter
   5          96        26       3692  0.00%  0.04%  0.01%   0 Check heaps
  17         204        76       2684  0.00%  0.07%  0.05%   0 HC Counter Timer
  23           4       252         15  0.08%  0.00%  0.00%   0 GraphIt
  31           0       253          0  0.08%  0.01%  0.00%   0 Per-Second Jobs
  47         576        52      11076  0.32%  0.25%  0.14%   0 Compute load avg
  48          24         5       4800  0.00%  0.01%  0.00%   0 Per-minute Jobs
  64         708       234       3025  0.24%  0.04%  0.11%   0 Exec
  77           0       981          0  0.00%  0.01%  0.00%   0 SSS Feature Time
  85          88        17       5176  0.00%  0.04%  0.00%   0 IP Background
  94         140      2504         55  0.00%  0.10%  0.08%   0 RBSCP Background
  97          56         6       9333  0.00%  0.03%  0.00%   0 Adj Manager
 100          76       498        152  0.00%  0.03%  0.02%   0 CEF process
 104         336       252       1333  0.16%  0.20%  0.09%   0 RUDPV1 Main Proc
 121           4        95         42  0.08%  0.01%  0.00%   0 FLEX DSPRM MAIN
 165          96        17       5647  0.00%  0.02%  0.00%   0 BGP Scanner

However, I bet you don’t want to type those 0.00% 0.00% 0.00%.

There is actually another shorther way to show this information.

router#sh proc cpu sorted
CPU utilization for five seconds: 2%/47%; one minute: 1%; five minutes: 1%
 PID Runtime(ms)   Invoked      uSecs   5Sec   1Min   5Min TTY Process
  64        1884       497       3790  0.81%  0.44%  0.34%   0 Exec
  47        1000       100      10000  0.40%  0.20%  0.17%   0 Compute load avg
 104         780       491       1588  0.24%  0.11%  0.13%   0 RUDPV1 Main Proc
 100         376       920        408  0.24%  0.22%  0.09%   0 CEF process
  94         160      4897         32  0.08%  0.08%  0.08%   0 RBSCP Background
   2          80       100        800  0.08%  0.01%  0.00%   0 Load Meter
   5         276        55       5018  0.00%  0.07%  0.03%   0 Check heaps
   6           0         1          0  0.00%  0.00%  0.00%   0 Pool Manager
   7           0         2          0  0.00%  0.00%  0.00%   0 Timers
   8           0         2          0  0.00%  0.00%  0.00%   0 Serial Backgroun
  11           0         1          0  0.00%  0.00%  0.00%   0 AAA_SERVER_DEADT
   4           0         1          0  0.00%  0.00%  0.00%   0 EDDRI_MAIN
   3          16        49        326  0.00%  0.00%  0.00%   0 OSPF-1 Hello
   9           4         1       4000  0.00%  0.00%  0.00%   0 Crash writer
  10           0         2          0  0.00%  0.00%  0.00%   0 AAA high-capacit
  12           0         1          0  0.00%  0.00%  0.00%   0 Policy Manager
  17         372       148       2513  0.00%  0.06%  0.07%   0 HC Counter Timer
  18           0         2          0  0.00%  0.00%  0.00%   0 DDR Timers
  19           8         2       4000  0.00%  0.00%  0.00%   0 Entity MIB API
  20           0         2          0  0.00%  0.00%  0.00%   0 ATM Idle Timer
  14           0         1          0  0.00%  0.00%  0.00%   0 OIR Handler
--More--

Just press Q to stop it from listing the rest of processes.

Top-N your NBAR result.

Once in a while your customer complaining that their network is slow. After checking using sh ip accounting command you realize that an IP is hammering the network with lots of downloads. You want to know what type of data using the most of the bandwidth.

Using options TOP-N will list the top N most active packets traversing a particular interface.

Router#sh ip nbar protocol-discovery top-n 5

 Ethernet1/0
                            Input                    Output
   Protocol                 Packet Count             Packet Count
                            Byte Count               Byte Count
                            30 second bit rate (bps) 30 second bit rate (bps)
   ------------------------ ------------------------ ------------------------
   rip                      2102906                  0
                            1111292596               0
                            4000                     0
   exchange                 445134                   476293
                            94999897                 71142644
                            1000                     0
   citrix                   17533000                 26189816
                            1699134115               1757238725
                            0                        0
   http                     757374                   531709
                            767270905                119874802
                            0                        0
   netbios                  273322                   286568
                            102971995                116649079
                            0                        0
   unknown                  1370743                  1286614
                            848454115                351384151
                            0                        0
   Total                    23608400                 29194373
                            4845810303               2530247355
                            5000                     0

DO it now!

You want to do sh command but you are in the global or interface configuration mode and you don’t like the idea to keep doing CTRL-Z and re-entering the configuration mode. Just DO it!

You can also use the rest of the command in user EXEC mode like clear, debug, wr, etc.

s1r1(config-router)#do sh ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            1.1.1.9         YES NVRAM  up                    up
Serial1/0                  unassigned      YES NVRAM  administratively down down
Serial1/1                  unassigned      YES NVRAM  administratively down down
Serial1/2                  unassigned      YES NVRAM  administratively down down
Serial1/3                  unassigned      YES NVRAM  administratively down down
Loopback0                  1.1.1.1         YES NVRAM  up                    up

NO ip domain-lookup.

You probably know that command no ip domain-lookup will make your router not to check to DNS server for every name or IP that you enter. You also probably know that using this command will save your life when you accidently mis-typed something.

router#pong
Translating "pong"...domain server (255.255.255.255)
 (255.255.255.255)
Translating "pong"...domain server (255.255.255.255)
% Unknown command or computer name, or unable to find computer address

But, do you know that it can also making your traceroute faster? NO ip domain-lookup will make your traceroute NOT to try resolve each IP thus will make your traceroute faster.

SECTION your sh run

I used sh run | begin router bgp to show my BGP configuration. This command will show the configuration BEGIN with the word router bgp

router#sh run | begin router bgp
router bgp 1
 no synchronization
 bgp log-neighbor-changes
 neighbor IBGP-PEERS peer-group
 neighbor IBGP-PEERS update-source Loopback0
 neighbor 1.1.1.2 remote-as 1
 neighbor 1.1.1.2 peer-group IBGP-PEERS
 neighbor 1.1.1.3 remote-as 1
 neighbor 1.1.1.3 peer-group IBGP-PEERS
 no auto-summary
!
ip http server
ip forward-protocol nd
!
!
!
!
!
!
control-plane
!
!
!
 --More--

However, it will also show anything that comes after BGP configuration.

Use SECTION to show ONLY your BGP configuration.

router#sh run | section router bgp
router bgp 1
 no synchronization
 bgp log-neighbor-changes
 neighbor IBGP-PEERS peer-group
 neighbor IBGP-PEERS update-source Loopback0
 neighbor 1.1.1.2 remote-as 1
 neighbor 1.1.1.2 peer-group IBGP-PEERS
 neighbor 1.1.1.3 remote-as 1
 neighbor 1.1.1.3 peer-group IBGP-PEERS
 no auto-summary
router#

It’s not no term mon but term no mon.

How do you think you going to cancel a command? put no in front of it. in this case, NO. Use command term no mon to disable term mon.

Extended but Shortcut.

You probably know that we can use extended ping which include particular source interface or source IP.

router#ping
Protocol [ip]:
Target IP address: 1.1.1.2
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 1.1.1.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/7/8 ms

We can actually make a shortcut from this. For example, as the above try to ping 1.1.1.2 with source address 1.1.1.1, we can use command

router#ping 1.1.1.2 so 1.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/12/20 ms
router#ping 1.1.1.2 re 1000 si 1500 so lo0      

Type escape sequence to abort.
Sending 1000, 1500-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (1000/1000), round-trip min/avg/max = 1/11/152 ms

Guess what? the above command is to
PING to 1.1.1.2
REpeat 1000 times
Packet SIze 1500-byte
SOurce address loopback0

Get RELOADed

If you plan to make a configuration change in one of the critical interface and afraid that your change can break the connection, you can use reload in 5 to reload your router in the next 5 minutes. Once you succesfully make the change and want to abort the reload command, just do reload cancel

router#reload in 5
Reload scheduled in 5 minutes by console
Reload reason: Reload Command
Proceed with reload? [confirm]
router#

***
*** — SHUTDOWN in 0:05:00 —
***

*Mar  1 01:53:29.491: %SYS-5-SCHEDULED_RELOAD: Reload requested for 01:58:25 UTC Fri
Mar 1 2002 at 01:53:25 UTC Fri Mar 1 2002 by console. Reload Reason: Reload Command.

router#reload cancel
router#

***
*** — SHUTDOWN ABORTED —
***

*Mar  1 01:53:41.567: %SYS-5-SCHEDULED_RELOAD_CANCELLED: Scheduled reload cancelled
at 01:53:41 UTC Fri Mar 1 2002

sadfasdfasdf

7 Responses to Cisco CLI Tips.

  1. Jammywanks

    Good work! I never knew of these shortcuts. I will use these shortcuts on my dynamips lab setups.

  2. Jammywanks

    UHHH your do show run under global configuration does not work.

    R1(config)#do show run
    ^
    % Invalid input detected at ‘^’ marker.

    R1(config)#do sh ip int brief
    ^
    % Invalid input detected at ‘^’ marker.

    R1(config)#do ?
    . Version number

    R1(config)#do 1 ?
    % Unrecognized command
    R1(config)#do 1.0 ?

    UMMM??? This is IOS 12.2

  3. Jammywanks

    why does ‘do’ command not work as said in this article?

  4. David Sudjiman

    @ Jimmy

    It depends on the IOS version. I’m using 12.4 train.

    Yet I couldn’t find any precise explanation which IOS version starts all of these.

    AFAIK, 12.3 would also do some of the job. (eg. sh run | b ospf but not sh run | s router ospf )

  5. Jammywanks

    I see then. Thanks a ton.

  6. Robert

    David,

    Thanks for taking the time to post this, some of these I knew, but the shortcut for extended ping and sorting processes I had no clue about. I really appreciate it.

    Thanks,

    Robert

  7. David Sudjiman
    router#ping 1.1.1.2 re 1000 si 1500 so lo0

    is

    PING to 1.1.1.2
    REpeat 1000 times
    Packet SIze 1500-byte
    SOurce address loopback0

    sh proc cpu sorted

    will sort all processes based on utilization.

Leave a Reply