How To: Cisco Embedded Packet Capture

WesM63

2[H]4U
Joined
Aug 29, 2004
Messages
3,266
Something I've been using a lot lately, this seems to be one of those things either you know about and use it or didn't know it even existed.

Basically, EPC is exactly what you'd think it is. Embedded packet capture built into Cisco IOS. Requires 12.4(20)T and higher.

The cool thing about this is you don't need to setup a SPAN to do a quick packet capture. If you've done enough packet captures, you know they're a pain in the ass. Take a laptop to where you are going to do the capture, configure the span (providing you have enough empty sessions and ports), run the capture, bring the laptop back, analyze the capture.. and so on.

I'm not going to go into the deep detail as how it works. Basically, it just buffers the capture into NVRAM (These values can be changed, buffer size, etc). You can view it directly from the router or export it via tftp/ftp/etc in pcap format to be viewed in wireshark.

Let's just jump into it.

I'm going to capture only telnet packets via an ACL.

1. Define the ACL. This is a standard ACL so the possibilities are pretty much endless. (This is only used by the capture, it doesn't get applied any where)
Code:
ip access-list extended Telnet
 permit tcp any any eq telnet
 permit tcp any eq telnet any

2. Define the capture buffer. This is where the capture will be stored in NVRAM. I'm also increasing the maximum element size to 100Kb and leaving the rest default.
Code:
monitor capture buffer buffer_23 max-size 100

3. Apply your access list to the capture buffer. Again, this part is optional but as you can imagine extremely helpful.
Code:
monitor capture buffer buffer_23 filter access-list Telnet

4. Define the capture point. This is where we define what interfaces and directions (ingress/egress) we want to capture. In this example, we want to capture on ALL interfaces in BOTH directions.
Code:
monitor capture point ip cef capture_23 all both

5. Next we're just associating the buffer with the capture point.
Code:
monitor capture point associate capture_23 buffer_23

6. Finally, start the capture.
Code:
monitor capture point start capture_23

7. Run through some test's! I just telnet to a known IP address on the internet. While doing this, you can verifiy by running a show command and watching the packets captured increase.
Code:
sh monitor capture buffer buffer_23 parameters
and an output..
Code:
Capture buffer buffer_23 (linear buffer)
Buffer Size : 262144 bytes, Max Element Size : 100 bytes, Packets : 4
Allow-nth-pak : 0, Duration : 0 (seconds), Max packets : 0, pps : 0
Associated Capture Points:
Name : capture_23, Status : Active
Configuration:
monitor capture buffer buffer_23 max-size 100 
monitor capture point associate capture_23 buffer_23
monitor capture buffer buffer_23 filter access-list Telnet

8. Stopping the capture.
Code:
monitor capture point stop capture_23

9. Export the capture, in this example I tftp the file to a server of mine.
Code:
monitor capture buffer buffer_23 export tftp://192.168.63.50/telnetcap.pcap

10. Removing the buffer.
Code:
no monitor capture buffer buffer_23

11. Remove the capture point.
Code:
no monitor capture point ip cef capture_23 all both

There you have it. Here is a screenshot from the imported .pacp file into wireshark. I filtered out my external IP address so no one gets any bright idea's. ;)

mmTIU.jpg
 
Last edited:
The 4000 series switches now actually have wireshark embedded in them I believe.

Nice stuff to have for sure since it can capture without worrying about a span port that is overloaded and you begin to not see information crossing the wire.
 
I saw captures mentioned in the Orange covered Firewall book by cisco.
First and only time for IOS device.
 
Back
Top