1.Cisco系列交换机配置端口镜像

cisco#conf t                                     //进入全局配置模式

Enter configuration commands, one per line.  End with CNTL/Z.

cisco(config)#monitor session 1 source interface g5/1 ?

  ,     Specify another range of interfaces            //不连续地指定多个源镜像端口

  -     Specify a range of interfaces               //连续地指定多个源镜像端口

  both  Monitor received and transmitted traffic   //将发送与接收均作镜像

  rx    Monitor received traffic only               //仅将收到的流量作镜像

  tx    Monitor transmitted traffic only             //仅将发送的流量作镜像      

  <cr>

 

cisco(config)#monitor session 1 source interface g5/1  //指定g5/1为源镜像端口,缺省为both

 

cisco(config)#monitor session 1 destination interface g5/8  //指定g5/8为镜像目的端口

cisco#sh monitor session ?                       //查看配置的镜像端口状态

  <1-16>              SPAN session number

  all                 Show all SPAN sessions

  erspan-destination  Show only Destination ERSPAN sessions

  erspan-source       Show only Source ERSPAN sessions

  local               Show only Local SPAN sessions

  range               Show a range of SPAN sessions in the box

  remote              Show only Remote SPAN sessions

 

cisco#sh monitor session 1

Session 1

---------

Type                   : Local Session

Source Ports           :

    Both               : Gi5/1

Destination Ports      : Gi5/8

    Encapsulation      : Native

          Ingress      : Disabled

         Learning : Disabled

Filter Pkt Type        :

    RX Only       : Good

 注意:启用了端口镜像的端口,在查看端口时会发现协议为none,是正常情况,表示该接口不再运行其他协议


2.H3C系列交换机配置端口镜像抓包

[H3C]monitor-port g0/10        //设置镜像端口即监控端口 10 为交换机端口编号

 

[H3C]mirroring-port g0/23     //设置被镜像端口即被监控端口 23 为交换机端口编号,如果需要多个连续的端口的命令式 mirroring-port g0/3 to mirroring-port g0/22即为被监控端口为编号3-22口。取消被监控端口的方法为 undo mirroring-port g0/XXX

 

[H3C]dis mir                                   //显示所有端口镜像信息

 

Monitor-port:

GigabitEthernet0/10

Mirroring-port:

GigabitEthernet0/23

 

[H3C]q                                     //退出端口镜像设置

 

[H3C]save                                //将配置后的信息保存

 

This will save the configuration in the EEPROM memory