Skip to Content

Ninja your way through a running-config

Do you use the command line often? If so, you probably have a set of go-to commands that get you the information you need. One of the staple commands I use is "show run"or show running-config if you want to type it out. The only problem with show run is it gives you the whole config. Often the output is dozens of pages long and can take time to flip through. Here are the shortcuts I use to speed this up..

Forward slash    /

You can use the forward slash after issuing the show run command to search for a specific string of text. I use this a lot when I want to jump to specific range of interfaces. For example, I want to see the configuration for interfaces g0/19, g0/22, and g0/24. I don't feel like typing show run int g0/19 then typing it all over again for the other two interfaces. Simply type show run and then hit /   then type your search string, in this case "0/19" will get you there.

SW3#show run
Building configuration...

Current configuration : 4355 bytes
!
version 12.2
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname SW3
!
enable password cisco
!
no aaa new-model
ip subnet-zero
ip routing
no ip domain-lookup
!
!
!
crypto pki trustpoint TP-self-signed-1699211256
 enrollment selfsigned
 subject-name cn=IOS-Self-Signed-Certificate-1699211256
/0/19     
filtering...
interface FastEthernet0/19
 switchport mode dynamic desirable
!
interface FastEthernet0/20
 switchport mode dynamic desirable
!
interface FastEthernet0/21
 switchport mode dynamic desirable

You could also use show run | begin 0/19, but I tend to just type show run then hit the / key.

Pipe  | include

The pipe at the end of the show run command gives you a lot of options. As mentioned above, you can use | begin to start the output at the first match of your text string. But what if you want to just see a specific line of text? You can use | include to list any line of text with a matching string. Here's an example:

SW1#show running-config | include spann
spanning-tree mode pvst
spanning-tree extend system-id
 spanning-tree portfast
 spanning-tree portfast

Pipe | section

This works if you are simply looking for a keyword or a specific string of text. But what if you want all the config associated with a section of the config, for example the routing protocols? To do this, use the section keyword:

R4#show run | section router
router rip
 version 2
 timers basic 10 60 60 80
 network 10.1.0.0
 network 10.51.0.0
 network 10.12.1.0
 no auto-summary

As you can see, it's a clean section of the config, not just a one liner.

show run partition

There's one catch - not all platforms support the | section keyword. If you find yourself on a catalyst 35xx, you might get the following output:

SW3#show run | section router
                    ^
% Invalid input detected at '^' marker.

Don't fret, there's another way to get sections of the running-config from a catalyst. The show run partition keyword gives you access to all of the following sections of the running-config:

SW3#show run partition ?
  access-list       All access-list configurations
  class-map         All class-map configurations
  common            All remaining unregistered configurations
  global-cdp        All global cdp configurations
  interface         Each Interface specific Configurations
  ip-as-path        All IP as-path configurations
  ip-community      All IP community list configurations
  ip-domain-list    All ip domain list configurations
  ip-prefix-list    All ip prefix-list configurations
  ip-static-routes  All IP static configurations
  line              All line mode configurations
  policy-map        All policy-map configurations
  route-map         All route-map configurations
  router            All routing configurations
  snmp              All SNMP configurations
  tacacs            All TACACS configurations

The one downside of this is you have to be very specific, you can't just say "show run part router" and have it give you all routing protocol configs, it needs to know the specific section. Here's an example:

SW3#show run part router
% Incomplete command.

SW3#show run part router rip
Building configuration...

Current configuration : 160 bytes
!
Configuration of Partition - router rip
!
!
!
router rip
 version 2
 timers basic 10 60 60 80
 network 10.1.0.0
 network 10.51.0.0
 no auto-summary
!
!
end

SW3#

There are a ton of ways to ninja through configs. If you have a favorite one I haven't listed here, feel free to post in the comments below.

Your rating: None Average: 5 (5 votes)

Comments

jimjim84's picture

Oh nice, never knew about the

Oh nice, never knew about the partition command. Was always bummed when I was on a catalyst switch and wanted to run the section command.

PacketPushers had an article with some more advanced command line output features a while back:
http://packetpushers.net/rocking-your-show-commands-with-regex/



Dr. Radut | blog