Skip Links

Introductions and IOS Output Filters

Be More Efficient with the Redirect Command

By Jerold Swan on Fri, 04/30/10 - 10:56am.

First off, let me introduce myself and the blog. I'll be guest blogging for the month of May. I'm a network engineer for a mid-sized company in Colorado. I've been in IT for about 15 years, with about 10 years devoted to network infrastructure, focusing mostly on Cisco products. During this time I spent four years as a Cisco instructor for Global Knowledge, teaching all the CCNA and CCNP courses. Before stating in the infrastructure world, I did system administration, mostly in the UNIX/Linux realm. I got my CCIE in Routing & Switching in 2007. My main areas of interest are routing protocols, security, and network management. I've been working with Cisco Press on a variety of projects for many years, and I've been a co-author on a couple of certification-related titles.

Rather than focus only on certification-specific topics, what I'd like to do in this guest blog is share some operational tips and tricks that may help engineers in small to mid-sized organizations be more productive in Cisco IOS. I'm going to try to aim this at engineers somewhere around the CCNA level. By that I mean that you have a solid understanding of basic networking, a basic understanding of the IOS command-line interface, and a basic understanding of routing and switching, but you probably don't spend your entire day doing pure networking or living in IOS (yet).

Many of the features I'm going to discuss are IOS version-dependent: they may have been released in relatively recent versions of IOS, or they might appear only in certain feature sets. Since I don't spend my life keeping track of IOS release notes, I'll only mention this issue if I know about it off the top of my head. In general, however, my examples are taken from fairly recent 12.4T images running on ISR or 7200 hardware.

The first thing I want to do is take a look at the command-line filters available in IOS (or, as IOS itself calls them, "output modifiers"). When the IOS output modifiers first came out, the only ones available were "begin", "include", and "exclude". Now there are quite a few:

Test#show version | ?
  append    Append redirected output to URL (URLs supporting append operation only)
  begin     Begin with the line that matches
  exclude   Exclude lines that match
  format    Format the output using the specified spec file
  include   Include lines that match
  redirect  Redirect output to URL
  section   Filter a section of output
  tee       Copy output to URL

One of the most useful but least-used of the output modifiers is "redirect". This allows you to take the output of one command and send it to any URL-formatted destination that your IOS version understands. What use is this? Well, what's the first thing that always shows up in your email when you open a new TAC case? Answer: "Please send the output of 'show tech-support'". They always ask for it, even if they don't need it to answer your question.

I almost always attach a "show tech" to the case notes when I open the case, before they have a chance to ask for it--it saves a step. I absolutely hate the process of setting up my terminal emulator to log to a text file and waiting for the command to complete. What's much faster is using the redirect filter to save the output via the transfer protocol of your choice:

Test#sh tech | redirect tftp://10.1.1.5/test-shTech.txt
!
Test#

If TFTP isn't your tool of choice, you can use FTP, SCP (for the security conscious), or on a platform with external USB ports you can even save it to usbflash0:.

The "append" modifier is helpful when you need to save the output of a series of commands, but you can't or don't want to log your terminal session:

Test#sh version | append flash:output.txt

Test#sh run | append flash:output.txt

Test#more flash:output.txt
[output omitted]
Cisco 1841 (revision 6.0) with 238592K/23552K bytes of memory.
2 FastEthernet interfaces
1 Virtual Private Network (VPN) Module
DRAM configuration is 64 bits wide with parity disabled.
191K bytes of NVRAM.
62720K bytes of ATA CompactFlash (Read/Write)

Configuration register is 0x2102


Building configuration...

Current configuration : 1575 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec

Unfortunately, most filesystem types don't support the append operation. Although the IOS documentation shows examples with FTP and TFTP, I could only get it to work with the flash filesystem.

That's it for today. Tune in next time for more...

 

On The Web
Twitter