三层交换机之端口镜像(Mirror)

端口镜像(Mirror)是指将报文从一个端口镜像到其他端口的技术,通常用于在不影响业务流的情况下分析报文,排查问题。

本文以博通交换芯片平台为例,介绍三层交换机端口镜像(Mirror)的几种实现方式。

 

1、上联口或者槽位口镜像

将上联口或者槽位口的报文镜像到其他上联口,具体实现上又分为两种——指定VLAN镜像、所有VLAN镜像。

这两种方式是由交换芯片的工作模式决定的:

#include <bcm/switch.h>
int bcm_switch_control_set(int unit, bcm_switch_control_t type, int arg);
int bcm_switch_control_get(int unit, bcm_switch_control_t type, int *arg);

Mirror to trunk groups is only supported on StrataXGS III switch chips, and 
in order to use this feature,bcmSwitchDirectedMirroring must be set to 1. If the bcmSwitchDirectedMirroring switch control is disabled(or unsupported),
the mirror-to port must be a member of the same VLANs as the mirrored port.

1.1、指定VLAN镜像

三层交换机的物理端口一般会配置加入VLAN转发域,才能参与报文转发。指定VLAN镜像就是指某个端口的报文镜像到镜像端口,镜像端口要在指定的VLAN内,这样就可以过滤指定VLAN的报文。

我司三层交换机可以通过网管创建Mirror端口镜像和VLAN添加端口实现。

 

监视端口:上联口

被监视端口:上联口、槽位口

方向:上行、下行、双向

备注:使用时,监视端口需要配置VLAN添加端口属性,指定要镜像的报文的VLAN

1.2、所有VLAN镜像

使用BCM命令dmirror实现,无视镜像端口是否在VLAN转发域。

 

此外,BCM提供的mirror命令可以实现更细粒度的端口镜像,如指定MAC、VLAN等。

 

2、ONU端口镜像

ONU端口镜像由ONU实现,将指定LAN口的所有报文镜像到其他LAN口,不过滤VLAN

 

监视端口:ONU LAN口

被监视端口:ONU LAN口

方向:上行、下行、双向

 

3、流镜像

流镜像一般是通过IFP重定向规则实现,我司三层交换机可以通过网管创建流分类规则实现。

 

我司三层交换机端口镜像相关命令:

Admin\maintenance\mirror#
1) CPU/Trunk组/物理端口镜像
set mirror source [port|trunk] <portlist> destination [port|trunk] <portlist> direction <0-2>
set mirror source cpu destination uplink slot <slotno> port <portno> direction <0-2>
set mirror disable
show mirror_info
2) ONU端口镜像
set onu_port_mirror disable slot <slotno> pon <ponno> onu <onuno> {mirroredport <portlist>}*1
set onu_port_mirror enable slot <slotno> pon <ponno> onu <onuno> {mirrorport <1-24> mirroredport <portlist> direction <0-2>}*1
apply onuportmirrorapply slot <slotno> pon <ponno> onu <onuno>
show onuportmirror slot <slotno> pon <ponno> onu <onuno>

posted on 2020-09-09 15:29  者旨於陽  阅读(3472)  评论(0编辑  收藏  举报

导航