这是 network/port-mirror.md 的每次改动内容,按时间从新到旧。其他文章一起提交的部分不会出现在这里。
#1
2026-10-18
+79
−0
docs: 新增邮件系统、VPN 分类,网络设备补 BGP/QinQ/IRF/镜像 4 篇
60178fc
new file mode 100644
@@ -0,0 +1,79 @@
+---
+tags: [端口镜像, 抓包, 排障]
+order: 105
+---
+
+# 端口镜像与抓包
+
+## 场景
+
+要抓某台服务器的流量分析,但服务器上没有 tcpdump,或者交换机上就能看。
+
+## 前置条件
+
+- 有一台能接镜像口的分析机(装了 Wireshark 或 tcpdump)
+- 知道要镜像哪个口、哪个方向
+- 交换机支持本地镜像
+
+## 配置
+
+### H3C
+
+```text
+system-view
+mirroring-group 1 local
+
+interface GigabitEthernet1/0/1
+ mirroring-group 1 mirroring-port both
+ quit
+
+interface GigabitEthernet1/0/24
+ mirroring-group 1 monitor-port
+ quit
+```
+
+### 华为
+
+```text
+system-view
+observe-port 1 interface GigabitEthernet0/0/24
+
+interface GigabitEthernet0/0/1
+ port-mirroring to observe-port 1 both
+ quit
+```
+
+`both` 是双向,也可以 `inbound` / `outbound`。
+
+## 验证
+
+分析机上:
+
+```bash
+tcpdump -i eth0 -nn -c 20
+ip -s link show eth0
+```
+
+能看到流量就说明镜像生效。
+
+## 回滚
+
+```text
+undo mirroring-group 1
+```
+
+或者:
+
+```text
+interface GigabitEthernet0/0/1
+ undo port-mirroring to observe-port 1
+```
+
+## 坑
+
+- **镜像口不能再当业务口用**,接上去的机器只能抓包。
+- 镜像流量可能超过分析机网卡能力,丢包导致分析结论错。
+- 镜像口和业务口在同一个 VLAN 时,可能产生环路。
+- 双向镜像在高峰时段流量翻倍,交换机 CPU 会上去。
+- 只镜像一个方向会看不出完整会话。
+- 抓包文件别存系统盘,半小时就能写几个 G。