{"id":532,"date":"2025-03-13T14:07:21","date_gmt":"2025-03-13T14:07:21","guid":{"rendered":"https:\/\/blog.devops955.com\/swain\/?p=532"},"modified":"2025-03-13T06:07:32","modified_gmt":"2025-03-13T06:07:32","slug":"capture-packet-on-cisco-switch","status":"publish","type":"post","link":"https:\/\/blog.devops955.com\/swain\/zh\/2025\/03\/13\/capture-packet-on-cisco-switch\/","title":{"rendered":"\u5982\u4f55\u5728Cisco\u4ea4\u6362\u673a\u4e0a\u4f7f\u7528Embedded\u6293\u5305"},"content":{"rendered":"<blockquote>\n<p>\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\uff1a8 \u5206\u949f<\/p>\n<\/blockquote>\n<h1>\u4ec0\u4e48\u662fCisco Embedded Packet Capture (EPC)<\/h1>\n<p>Embedded Packet Capture \u662f\u4e00\u79cd\u5d4c\u5165\u5f0f\u7cfb\u7edf\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u4e8e\u8ddf\u8e2a\u548c\u6392\u67e5\u7f51\u7edc\u6570\u636e\u5305\u3002\u8fd9\u4e2a\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u7f51\u7edc\u7ba1\u7406\u5458\u6355\u83b7Cisco\u8bbe\u5907\u6d41\u5165\u6d41\u51fa\u7684\u6570\u636e\u5305\u3002<br \/>\n\u8fd9\u4e2a\u5de5\u5177\u53ef\u4ee5\u914d\u5408ACL\u4f7f\u7528\uff0c\u901a\u8fc7ACL\u89c4\u5219\u8fc7\u6ee4\u51fa\u9700\u8981\u6293\u53d6\u7684\u6570\u636e\u5305\uff0c\u7136\u540e\u901a\u8fc7EPC\u5de5\u5177\u8fdb\u884c\u7279\u5b9a\u7684\u6570\u636e\u5305\u6293\u53d6\u3002\u6293\u53d6\u7684\u6570\u636e\u5305\u662f\u5b58\u50a8\u5728DRAM\u7684buffer\u4e2d\uff0c\u56e0\u6b64\u4e0d\u4f1a\u6c38\u4e45\u6027\u4fdd\u5b58\uff0c\u5982\u679c\u9700\u8981\u4fdd\u5b58\u6293\u5305\u6570\u636e\uff0c\u53ef\u4ee5\u4fdd\u5b58\u4e3aPCAP\u6587\u4ef6\uff0c\u7136\u540e\u901a\u8fc7Wireshark\u7b49\u5de5\u5177\u8fdb\u884c\u5206\u6790\u3002<\/p>\n<p>\u4f7f\u7528\u8fd9\u4e2a\u5de5\u5177\u524d\u9700\u8981\u5148\u786e\u8ba4\u8f6f\u4ef6\u7248\u672c\uff0c\u76ee\u524d\u53ea\u5728\u4ee5\u4e0b\u7248\u672c\u4e2d\u652f\u6301\uff1a<\/p>\n<ul>\n<li>Cisco IOS Release 12.4(20)T or later<\/li>\n<li>Cisco IOS XE Release 15.2(4)S - 3.7.0 or later<\/li>\n<\/ul>\n<h1>\u5982\u4f55\u4f7f\u7528EPC\u6293\u5305<\/h1>\n<p>\u6293\u5305\u524d\u51c6\u5907\u5de5\u4f5c<br \/>\n\u786e\u8ba4\u78c1\u76d8\u7a7a\u95f4\u5145\u8db3\uff1a <code>dir<\/code><br \/>\n\u786e\u8ba4CPU\u8d1f\u8f7d\uff1a <code>sh proc cpu<\/code><\/p>\n<h2>\u6293\u5305\u914d\u7f6e\u6b65\u9aa4<\/h2>\n<p>\u57fa\u672cEPC\u914d\u7f6e\uff1a<br \/>\n\u521b\u5efa\u4e00\u4e2a\u6293\u5305\u914d\u7f6e\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u5173\u8054ACL\u8fc7\u6ee4\u89c4\u5219\uff0c\u8bbe\u7f6ebuffer\u5927\u5c0f\uff0c\u6307\u5b9a\u6293\u5305\u63a5\u53e3\uff0c\u8bbe\u7f6e\u6293\u5305\u901f\u7387\u9650\u5236\uff0c\u6293\u5305\u65f6\u95f4\nmonitor capture test access-list capture buffer size 20 interface gi1\/0\/1 in limit pps 10000 duration 300\n# \u6307\u5b9a\u6293\u5305\u6587\u4ef6\u5b58\u50a8\u8def\u5f84\nmonitor capture test file location flash:test.pcap<\/code><\/pre>\n<p>\u786e\u8ba4\u5f53\u524d\u6293\u5305\u914d\u7f6e\uff1a<br \/>\n<code>show capture monitor test<\/code><\/p>\n<p>\u542f\u52a8\u548c\u505c\u6b62\u6293\u5305\uff1a<br \/>\n<code>capture monitor test start<\/code><br \/>\n<code>capture monitor test stop<\/code><\/p>\n<h2>\u6293\u5305\u53c2\u6570\u89e3\u6790<\/h2>\n<h3>\u6838\u5fc3\u547d\u4ee4\u7ed3\u6784<\/h3>\n<pre><code class=\"language-bash\">monitor capture &lt;capture-name&gt; [\u53c2\u6570] [\u8fc7\u6ee4\u6761\u4ef6] [\u9650\u5236\u6761\u4ef6]<\/code><\/pre>\n<h3>\u4e3b\u8981\u53c2\u6570\u8be6\u89e3<\/h3>\n<ol>\n<li>\n<p><strong>access-list<\/strong><br \/>\n\u6307\u5b9a\u9884\u5b9a\u4e49\u7684ACL\u8fc7\u6ee4\u89c4\u5219\uff08\u9700\u63d0\u524d\u914d\u7f6e\uff09<br \/>\n<em>\u793a\u4f8b<\/em>\uff1a<code>access-list capture<\/code> \u8868\u793a\u5f15\u7528\u540d\u4e3a&quot;capture&quot;\u7684ACL\u89c4\u5219  <\/p>\n<blockquote>\n<p>\u5efa\u8bae\uff1a\u5efa\u8bae\u521b\u5efa\u4e13\u95e8\u7528\u4e8e\u6293\u5305\u7684ACL\uff0c\u53ef\u5b9a\u4e49\u534f\u8bae\u7c7b\u578b\u3001IP\u5730\u5740\u3001\u7aef\u53e3\u53f7\u7b49\u8fc7\u6ee4\u6761\u4ef6<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p><strong>buffer size<\/strong><br \/>\n\u8bbe\u7f6e\u6293\u5305\u7f13\u5b58\u5927\u5c0f\uff08\u5355\u4f4d\uff1aMB\uff09<br \/>\n<em>\u793a\u4f8b<\/em>\uff1a<code>buffer size 20<\/code> \u5206\u914d20MB\u5185\u5b58\u4f5c\u4e3a\u6293\u5305\u7f13\u51b2\u533a  <\/p>\n<blockquote>\n<p>\u6ce8\u610f\uff1a\u8fc7\u5c0f\u4f1a\u5bfc\u81f4\u6570\u636e\u5305\u4e22\u5931\uff0c\u8fc7\u5927\u4f1a\u6d88\u8017\u8bbe\u5907\u5185\u5b58\u8d44\u6e90<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p><strong>interface<\/strong><br \/>\n\u6307\u5b9a\u6293\u5305\u63a5\u53e3\u53ca\u6d41\u91cf\u65b9\u5411\uff1a  <\/p>\n<ul>\n<li><code>interface gi1\/0\/1 in<\/code> \u6355\u83b7\u63a5\u53e3\u63a5\u6536\u65b9\u5411\u7684\u6d41\u91cf  <\/li>\n<li><code>out<\/code> \u6355\u83b7\u53d1\u9001\u65b9\u5411\u7684\u6d41\u91cf  <\/li>\n<li><code>both<\/code> \u53cc\u5411\u6355\u83b7\uff08\u9700\u8bbe\u5907\u652f\u6301\uff09<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>limit pps\/bps<\/strong><br \/>\n\u8bbe\u7f6e\u6293\u5305\u901f\u7387\u9650\u5236\uff1a  <\/p>\n<ul>\n<li><code>pps 10000<\/code> \u9650\u5236\u6bcf\u79d2\u6355\u83b7\u4e0d\u8d85\u8fc710,000\u4e2a\u6570\u636e\u5305  <\/li>\n<li><code>bps 100M<\/code> \u9650\u5236\u5e26\u5bbd\u4e3a100Mbps\uff08\u652f\u6301K\/M\/G\u5355\u4f4d\uff09<br \/>\n<blockquote>\n<p>\u6ce8\u610f\uff1a\u53ef\u9632\u6b62\u9ad8\u6d41\u91cf\u573a\u666f\u4e0b\u8bbe\u5907\u8d44\u6e90\u8017\u5c3d<\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>duration<\/strong><br \/>\n\u8bbe\u7f6e\u81ea\u52a8\u505c\u6b62\u65f6\u95f4\uff08\u5355\u4f4d\uff1a\u79d2\uff09<br \/>\n<em>\u793a\u4f8b<\/em>\uff1a<code>duration 300<\/code> \u8868\u793a\u6301\u7eed\u6293\u53055\u5206\u949f\u540e\u81ea\u52a8\u505c\u6b62<\/p>\n<\/li>\n<li>\n<p><strong>file location<\/strong><br \/>\n\u6307\u5b9a\u6293\u5305\u6587\u4ef6\u5b58\u50a8\u8def\u5f84\uff1a  <\/p>\n<ul>\n<li><code>flash:test.pcap<\/code> \u4fdd\u5b58\u5230\u8bbe\u5907\u95ea\u5b58  <\/li>\n<li><code>bootflash:<\/code>\/<code>usbflash:<\/code> \u5176\u4ed6\u5b58\u50a8\u8bbe\u5907\u8def\u5f84<br \/>\n<blockquote>\n<p>\u6ce8\u610f\uff1a\u786e\u4fdd\u76ee\u6807\u5b58\u50a8\u6709\u8db3\u591f\u7a7a\u95f4<\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u5176\u4ed6\u5e38\u7528\u53c2\u6570<\/h3>\n<ul>\n<li>\n<p><strong>circular-buffer<\/strong><br \/>\n\u542f\u7528\u5faa\u73af\u7f13\u51b2\u533a\u6a21\u5f0f\uff08\u5f53\u7f13\u51b2\u533a\u6ee1\u65f6\u8986\u76d6\u65e7\u6570\u636e\u5305\uff09<br \/>\n<em>\u793a\u4f8b<\/em>\uff1a<code>buffer circular size 50<\/code><\/p>\n<\/li>\n<li>\n<p><strong>match<\/strong><br \/>\n\u76f4\u63a5\u6307\u5b9a\u8fc7\u6ee4\u6761\u4ef6\uff08\u65e0\u9700ACL\uff09<br \/>\n<em>\u793a\u4f8b<\/em>\uff1a<code>match ipv4 protocol tcp any any<\/code><\/p>\n<\/li>\n<li>\n<p><strong>stop-after<\/strong><br \/>\n\u6355\u83b7\u6307\u5b9a\u6570\u91cf\u6570\u636e\u5305\u540e\u81ea\u52a8\u505c\u6b62<br \/>\n<em>\u793a\u4f8b<\/em>\uff1a<code>stop-after 1000<\/code> \u6293\u6ee11000\u4e2a\u5305\u505c\u6b62<\/p>\n<\/li>\n<\/ul>\n<h3>\u53c2\u6570\u914d\u7f6e\u5efa\u8bae<\/h3>\n<ol>\n<li>\u751f\u4ea7\u73af\u5883\u4e2d\u5efa\u8bae\u7ec4\u5408\u4f7f\u7528<code>limit<\/code>\u548c<code>duration<\/code>\u53c2\u6570\uff0c\u907f\u514d\u957f\u671f\u5360\u7528\u8d44\u6e90<\/li>\n<li>\u5b58\u50a8\u8def\u5f84\u63a8\u8350\u4f7f\u7528\u5916\u90e8\u5b58\u50a8\u8bbe\u5907\uff08\u5982USB\uff09\uff0c\u907f\u514d\u5360\u7528\u7cfb\u7edf\u95ea\u5b58\u7a7a\u95f4<\/li>\n<li>\u8c03\u8bd5\u573a\u666f\u53ef\u6dfb\u52a0<code>no-limit<\/code>\u53c2\u6570\u53d6\u6d88\u901f\u7387\u9650\u5236\uff0c\u4f46\u9700\u8c28\u614e\u4f7f\u7528<\/li>\n<li>\u4f7f\u7528<code>show memory statistics<\/code>\u68c0\u67e5\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u5408\u7406\u8bbe\u7f6ebuffer\u5927\u5c0f<\/li>\n<\/ol>\n<h1>\u600e\u4e48\u67e5\u770b\u6293\u5305<\/h1>\n<h2>\u4ea4\u6362\u673a\u76f4\u63a5\u67e5\u770b<\/h2>\n<pre><code class=\"language-bash\"># \u67e5\u770b\u6293\u5305\u7f13\u51b2\u533a\u6458\u8981\u4fe1\u606f\nshow monitor capture test buffer brief\n# \u663e\u793a\u524d50\u4e2a\u6570\u636e\u5305\u7684\u8be6\u7ec6\u89e3\u7801\nshow monitor capture test buffer detailed limit 50\n# \u5341\u516d\u8fdb\u5236\u539f\u59cb\u683c\u5f0f\u67e5\u770b\uff08\u8c03\u8bd5\u7528\uff09\nshow monitor capture test buffer dump<\/code><\/pre>\n<h3>\u67e5\u770b\u6293\u5305\u7edf\u8ba1\u4fe1\u606f<\/h3>\n<pre><code class=\"language-bash\"># \u663e\u793a\u6293\u5305\u8fd0\u884c\u72b6\u6001\nshow monitor capture test status\n# \u67e5\u770b\u5df2\u6355\u83b7\u6570\u636e\u5305\u8ba1\u6570\nshow monitor capture test packet-number<\/code><\/pre>\n<h2>\u4e0b\u8f7d\u6293\u5305\u6587\u4ef6\u67e5\u770b<\/h2>\n<h3>\u6587\u4ef6\u4f20\u8f93\u65b9\u6cd5<\/h3>\n<ol>\n<li>\n<p><strong>FTP\/TFTP\u4f20\u8f93<\/strong>\uff08\u63a8\u8350\u57fa\u7840\u65b9\u6cd5\uff09<\/p>\n<pre><code class=\"language-bash\"># \u4e0a\u4f20\u5230FTP\u670d\u52a1\u5668\ncopy flash:test.pcap ftp:\/\/username:password@10.1.1.100\/path\/\n# TFTP\u4f20\u8f93\u793a\u4f8b\ncopy flash:test.pcap tftp:\/\/10.1.1.100\/<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>SCP\u4f20\u8f93<\/strong>\uff08\u5b89\u5168\u4f20\u8f93\uff09<\/p>\n<pre><code class=\"language-bash\"># \u9700\u8981\u914d\u7f6eSSH\u670d\u52a1\u5668\ncopy flash:test.pcap scp:\/\/user@serverip:\/path\/<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>HTTP\u4e0b\u8f7d<\/strong>\uff08NX-OS\u652f\u6301\uff09<\/p>\n<pre><code class=\"language-bash\"># \u5148\u542f\u7528HTTP\u670d\u52a1\nfeature http\n# \u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\nhttps:\/\/switch-ip\/files\/test.pcap<\/code><\/pre>\n<\/li>\n<\/ol>\n<blockquote>\n<p>\u53c2\u8003\u8d44\u6599<br \/>\n<a href=\"https:\/\/www.cisco.com\/c\/en\/us\/td\/docs\/ios-xml\/ios\/epc\/configuration\/xe-17\/epc-xe-17-book\/nm-packet-capture-xe.html\">https:\/\/www.cisco.com\/c\/en\/us\/td\/docs\/ios-xml\/ios\/epc\/configuration\/xe-17\/epc-xe-17-book\/nm-packet-capture-xe.html<\/a><br \/>\n<a href=\"https:\/\/www.cisco.com\/c\/en\/us\/support\/docs\/ios-nx-os-software\/ios-embedded-packet-capture\/116045-productconfig-epc-00.html\">https:\/\/www.cisco.com\/c\/en\/us\/support\/docs\/ios-nx-os-software\/ios-embedded-packet-capture\/116045-productconfig-epc-00.html<\/a><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Cisco Embedded Packet Capture (EPC) \u662f\u4e00\u6b3e\u5185\u7f6e\u7684\u7f51\u7edc\u6545\u969c\u6392\u67e5\u5de5\u5177\uff0c\u53ef\u5728 Cisco \u8bbe\u5907\u4e0a\u76f4\u63a5\u6293\u53d6\u6570\u636e\u5305\u3002\u5b83\u652f\u6301 ACL \u8fc7\u6ee4\u3001\u81ea\u5b9a\u4e49\u7f13\u51b2\u533a\u5927\u5c0f\u3001\u901f\u7387\u9650\u5236\u548c\u65f6\u957f\u8bbe\u7f6e\uff0c\u5e76\u53ef\u5bfc\u51fa PCAP \u6587\u4ef6\u4f9b Wireshark \u5206\u6790\u3002\u672c\u6587\u4ecb\u7ecd\u4e86 EPC \u7684\u914d\u7f6e\u65b9\u6cd5\u3001\u5173\u952e\u53c2\u6570\u89e3\u6790\u3001\u6700\u4f73\u5b9e\u8df5\u53ca\u6293\u5305\u6570\u636e\u7684\u67e5\u770b\u4e0e\u4f20\u8f93\u65b9\u5f0f\u3002<\/p>\n","protected":false},"author":1,"featured_media":437,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[29],"tags":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/blog.devops955.com\/swain\/wp-content\/uploads\/sites\/2\/2024\/04\/cisco.png","_links":{"self":[{"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/posts\/532"}],"collection":[{"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/comments?post=532"}],"version-history":[{"count":9,"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/posts\/532\/revisions"}],"predecessor-version":[{"id":572,"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/posts\/532\/revisions\/572"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/media\/437"}],"wp:attachment":[{"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/media?parent=532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/categories?post=532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.devops955.com\/swain\/wp-json\/wp\/v2\/tags?post=532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}