Catalyst 4500X series (IOS-XE): CPUにPuntされたパケットのキャプチャを取得する

Catalyst 4500X (IOS-XE) で、CPUにPuntされたパケットのキャプチャを取得する方法のメモ。

router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
 ! ACLでパケットを絞る場合(大抵絞る)
router(config)#ip access-list extended ACL-monitor-cap01
 ! udp, srcip: any, srcport: any, dstip: any, dstport: 7
router(config-ext-nacl)#permit udp any any eq echo
router(config-ext-nacl)#exit
router(config)#end

 ! in, out, both から選択
router#monitor capture cap01 control-plane in
router#monitor capture cap01 access-list ACL-monitor-cap01
router#monitor capture cap01 limit packets 10
router#monitor capture cap01 file location bootflash:/cap01.pcap
 ! キャプチャ開始
router#monitor capture cap01 start
router#show monitor capture cap01
Status Information for Capture cap01
  Target Type:
   Interface: Control Plane, Direction : in
   Status : Active
  Filter Details:
   Access-list: ACL-monitor-cap01
  Buffer Details:
   Buffer Type: LINEAR (default)
  File Details:
   Associated file name: bootflash:/cap01.pcap
   Size of buffer(in MB): 1
  Limit Details:
   Number of Packets to capture: 10
   Packet Capture duration: 0 (no limit)
   Packet Size to capture: 0 (no limit)
   Packets per second: 0 (no limit)
   Packet sampling rate: 0 (no sampling)
router#monitor capture cap01 stop
router#dir bootflash:cap01.pcap
Directory of bootflash:/cap01.pcap

173547  -rw-          24  Nov 16 2023 14:41:13 +09:00  cap01.pcap

router#copy bootflash:cap01.pcap scp://hoge@example.net//tmp/cap01.pcap vrf huga

なお、IOS-XEでCPUにPuntされるパケットはおおよそ2種類がある

  1. ルータのインターフェイスIPアドレス宛のトラフィック(例: ルータ宛のPingパケット)
  2. ルータがCPUで処理する必要があるトランジットトラフィック(例: ルータ配下IPアドレス宛のパケットだが、宛先IPアドレスのARP解決が必要な場合)

特に2番目をキャプチャしたい場合は、トランジットトラフィックのパケットがそのままのヘッダでCPUにPuntされる点に留意が必要。(ACLのsrc/dstで落としがち)。ちなみにecho-modeのBFD helloのようなパケットはラインカードで折り返すのでキャプチャできない。