H3C交换机抓包:
在华三交换机上可使用:packet-capture 命令,在用户视图下执行。
具体操作可查看这:https://www.h3c.com/cn/d_202009/1327093_30005_0.htm
相关命令:查看端口
display interface
先停止抓包:
packet-capture stop
进入系统视图:sys
<Device> sys
#做流统匹配抓包流量:acl http://blog.sina.com.cn/s/blog_165c04adb0102yens.html
创建acl (记得先删除之前创建的--方法见文章末尾,或者取别号码3001等)
acl advanced 3000
description test
#rule 0 permit ip source 192.168.1.1 0 destination 192.168.2.1 0rule 0 deny ip destination 172.16.30.0 0.0.0.255 #禁止访问30段,允许其它
rule 5 permit ip #允许所有IP数据
#rule 10 permit source-mac xxxx-xxxx-xxxx #过滤mac,运行源macxxxx-xxxx-xxxx的数据
traffic classifier class_test operator andif-match acl 3000
#traffic classifier c2 operator and if-match acl 3002
#流量分类器 C2 算子 如果匹配ACL 3002
#定义一个类,名为c2;报文只有匹配了访问控制列表acl 3002的规则,设备才认为报文属于这个类#
traffic behavior behavior_test
accounting packet # 做流量统计
mirror-to cpu # 镜像到CPU,必须镜像到CPU才能抓包
#
qos policy policy_test
classifier class_test behavior behavior_test
#
interface HundredGigE1/0/4
qos apply policy policy_test inbound
检查配置状况:
display qos policy interface
退出系统视图Ctrl+Z
packet-capture local interface HundredGigE1/0/4 autostop filesize 50000 write flash:/isp1.cap#packet-capture local interface HundredGigE1/0/4 autostop filesize 50000 write flash:/isp4.cap
packet-capture stop # 及时停止。
远程抓包:packet-capture remote interface HundredGigE1/0/4 port 2014
需要注意的几点:
- 抓包时尽量使用acl匹配精确的流
- 在traffic behavior中,必须配置流量镜向到CPU。mirror-to cpu, 否则不能抓到包。
- 抓包时做好文件大小限制,autostop filesze 50000, 因为交换机的硬盘都很小,防止把交换机硬盘打满。
- 抓包时尽量选择流量低峰期。
- 配置accounting packet 流量统计后,可通过display qos policy interface 查看匹配情况。
packet-capture remote interface HundredGigE1/0/4 port 2015
display packet-capture status
删除策略
- 查看当前策略:
[H3C]sys
[H3C]display qos policy interface
Interface: HundredGigE1/0/4
Direction: Inbound
Policy: policy_test
Classifier: class_test
Operator: AND
Rule(s) :
If-match acl 3000
Behavior: behavior_test