端口镜像
通过配置镜像功能,可以将报文复制到特定的目的地进行分析,以进行网络监控和故障定位。
通俗来讲,镜像是指将经过指定端口(源端口或者镜像端口)的报文复制一份到另一个指定端口(目的端口或者观察端口)。
如下图所示:

在华为中,交换机上做镜像的网口叫做镜像端口,连接监控设备的接口叫做观察口。
一般端口镜像分为1对1 ,1对多,多对1等情况,下面通过简单的案例来进行学习:
1、1对1本地端口镜像(一台监控设备连接一个镜像端口)
测试拓扑图如下所示:

现在我要把LSW1上GE0/0/2接口的流量镜像到GE0/0/1接口上,配置如下:
observe-port 1 interfaceGigabitEthernet0/0/2 #观察口
interface GigabitEthernet0/0/1 #镜像口
port-mirroring to observe-port 1 both #镜像上下行流量
可以在设备上通过dis cu命令来查看配置:

此时,我们在PC1上设置开始不停的往LSW1发包:

然后在LSW1上的GE0/0/1口进行抓包,如果有对应的数据的话,说明镜像是OK的:


我们可以清晰的看到由源地址10.10.10.10发往10.10.10.1的数据包,说明镜像做的是正常的。
2、多对一端口本地端口镜像(多个监控设备同时监控一个端口)
实验拓扑图如下所示:

由于在配置的时候发生了一个小的插曲,如下:

也就是说设备的每一个插槽只能配置一个观察口,而模拟器上面又不能自助式的配添加插槽,所以这里只把对应的配置列出来:
方法一:(单个配置观察端口)
observe-port 1 interfaceGigabitEthernet0/0/1 #观察口1
observe-port 2 interfaceGigabitEthernet0/0/3 #观察口2
interface GigabitEthernet0/0/2 #镜像口
port-mirroring to observe-port 1 both #镜像上下行流
port-mirroring to observe-port 2 both #镜像上下行流
方法二:(批量配置观察端口)
observe-port 1 interface-range G 0/0/X to G0/0/Y #端口X到Y为观察口
interface GigabitEthernet1/0/1 #镜像口
port-mirroring to observe-port 1 both #镜像上下行流
3、一对多端口镜像配置(一个监控设备监控多个端口)
测试拓扑图如下所示:
