在交换机上抓包,一般可排查一些网络问题。下面是总结的在各厂商交换机上抓包方式。
H3C交换机抓包
在华三交换机上可使用:packet-capture 命令,在用户视图下执行。
#做流统匹配抓包流量
acl advanced 3000
description test
rule 0 permit ip source 192.168.1.1 0 destination 192.168.2.1 0
traffic classifier class_test operator and
if-match acl 3000
#
traffic behavior behavior_test
accounting packet # 做流量统计
mirror-to cpu # 镜像到CPU,必须镜像到CPU才能抓包
#
qos policy policy_test
classifier class_test behavior behavior_test
#
interface Ten-GigabitEthernet1/3/1
qos apply policy policy_test inbound
packet-capture local interface Ten-GigabitEthernet 1/3/1 autostop filesize 50000 write flash:/isp1.cap
packet-capture stop # 及时停止。
需要注意的几点:
1、抓包时尽量使用acl匹配精确的流 2、在traffic behavior中,必须配置流量镜向到CPU。mirror-to cpu, 否则不能抓到包。 3、抓包时做好文件大小限制,autostop filesze 50000, 因为交换机的硬盘都很小,防止把交换机硬盘打满。 4、抓包时尽量选择流量低峰期。 5、配置accounting packet 流量统计后,可通过display qos policy interface 查看匹配情况。华为交换机抓包:
华为交换机抓包
华为交换机抓包使用:capture-packet 命令,在用户视图下执行。
capture-packet interface 10GE 1/0/5 acl 3000 destination file file.cap packet-num 1000 packet-len 1000
undo capture-packet # 关闭报文捕获。
注意事项:做好抓包限制,防止打满硬盘。