端口镜像集锦

交换机端口镜像资料收集整理

1 端口镜像简介
1.1 端口镜像简介
镜像一般是将符合指定规则的报文复制到镜像目的端口。一般镜像目的端口会接入数据检测设备,用户利用这些设备对镜像过来的报文进行分析,进行网络监控和故障排除等。

图1-1 镜像示意图
1.1.1  端口镜像的定义
端口镜像,即把交换机一个或多个端口(VLAN)的数据镜像到一个或多个端口的方法。
1.1.2  端口镜像的目的
通常为了部署 IDS 产品需要监听网络流量(网络分析仪同样也需要),但是在目前广泛采用的交换网络中监听所有流量有相当大的困难,因此需要通过配置交换机来把一个或多个端口(VLAN)的数据转发到某一个端口来实现对网络的监听。
1.1.3  端口镜像的别名
端口镜像通常有以下几种别名:
        Port Mirroring :
     通常指允许把一个端口的流量复制到另外一个端口,同时这个端口不能再传输数据。
        Monitoring Port :
     监控端口
        Spanning Port :
     通常指允许把所有端口的流量复制到另外一个端口,同时这个端口不能再传输数据。
        SPAN port :
     在 Cisco 产品中,SPAN 通常指 Switch Port ANalyzer。某些交换机的 SPAN 端口不支持传输数据。
        Link Mode port :
1.1.4  支持端口镜像的交换机

        大多数中档以上的交换机都支持端口镜像功能,但支持程度不同。

1.2 端口镜像的类型
1.2.1  远程端口镜像
远程端口镜像,突破了镜像源端口和镜像目的端口必须在同一台交换机上的限制,使镜像源端口和镜像目的端口可以在不同的网络设备上,从而方便网管人员对远程交换机设备进行管理。远程端口镜像的应用示意图如下所示。

图1-2 远程端口镜像应用示意图
实现了远程端口镜像功能的交换机分为三种:
        源交换机:被监测的端口所在的交换机,负责将镜像流量复制到Remote-probe VLAN中,然后二层转发给中间交换机或目的交换机。
        中间交换机:网络中处于源交换机和目的交换机之间的交换机,通过Remote-probe VLAN把镜像流量传输给下一个中间交换机或目的交换机。如果源交换机与目的交换机直接相连,则不存在中间交换机。
        目的交换机:远程镜像目的端口所在的交换机,将从Remote-probe VLAN接收到的镜像流量通过镜像目的端口转发给监控设备。


说明:
在交换机作为远程镜像的中间设备或目的设备时,为了保证数据镜像的正常实现,建议用户在入接口上配置重定向,将Remote-probe VLAN内的报文全部重定向到相应的出接口(中间设备)或镜像目的端口(目的设备)。
各个交换机上参与镜像的端口如表1-1所示。
表1-1 交换机上参与镜像的端口
交换机        参与镜像的端口        作用
源交换机        源端口(Source Port)        被监测的用户端口,通过本地端口镜像把用户数据报文复制到指定的反射端口(Reflector port),源端口可以有多个
        反射端口(Reflector port)        接收本地端口镜像的用户数据报文
        Trunk端口        将镜像报文发送到中间交换机或者目的交换机
中间交换机        Trunk端口        将镜像报文发送到目的交换机
中间交换机上要配置两个Trunk端口,和两侧的设备相连
目的交换机        Trunk端口        接收远程镜像报文
        镜像目的端口(Destination port)        远程镜像报文的监控端口

为了实现远程端口镜像功能,需要定义一个特殊的VLAN,称之为Remote-probe VLAN。这个VLAN只传输镜像报文,不能用来承载正常的业务数据。所有被镜像的报文通过该VLAN从源交换机传递到目的交换机的指定端口,实现在目的交换机上对源交换机的远程端口的报文进行监控的功能。对Remote-probe VLAN有以下要求:
              建议将该VLAN中的设备互连端口都配置为Trunk端口。
              不能将缺省VLAN、管理VLAN设置成Remote-probe vlan。
              需要通过配置保证Remote-probe VLAN从源交换机到目的交换机的二层互通性。
   注意:
建议用户不要在Remote-probe VLAN上进行以下操作,否则可能影响报文镜像效果:
      将镜像源端口配置到本镜像组所使用的Remote-probe VLAN中。
      配置Remote-probe VLAN的三层接口。
      运行其他协议报文,承载其他的业务报文。
      将Remote-probe VLAN用作其他特殊类型的VLAN,如voice VLAN、协议VLAN。
      配置其他与VLAN相关的功能。
1.2.2  流镜像
流镜像就是将匹配ACL规则的业务流复制到指定的本地端口,用于报文分析和监视。在配置流镜像前用户需要先定义符合需求的ACL规则,设备会引用这些ACL规则进行流识别。
1.2.3  远程流镜像
远程流镜像就是将匹配ACL规则的业务流复制到指定镜像组的反射端口,配合远程端口镜像的相应配置最终把匹配的业务流复制到其它设备的指定端口上。类似于本地流镜像,用户需要在配置镜像前预先定义符合需求的ACL规则。另外,用户需要完成远程端口镜像的全部配置(配置镜像源端口除外)。
1.3 端口镜像SPAN/RSPAN详解
1.3.1  SPAN简介
    SPAN技术主要是用来监控交换机上的数据流,大体分为两种类型,本地SPAN和远程SPAN. ----Local Switched Port Analyzer (SPAN) and Remote SPAN (RSPAN),实现方法上稍有不同。
    利用SPAN技术我们可以把交换机上某些想要被监控端口(以下简称受控端口)的数据流COPY或MIRROR一份,发送给连接在监控端口上的流量分析仪,比如CISCO的IDS或是装了SNIFFER工具的PC. 受控端口和监控端口可以在同一台交换机上(本地SPAN),也可以在不同的交换机上(远程SPAN)。



1.3.2  名词解释
SPAN Session--SPAN会话
    SPAN会话是指一组受控端口与一个监控端口之间的数据流。可以同时对多个端口的进入流量或是一个端口的外出流量进行监控,也可以对VLAN内所有端口的进入流量进行监控,但不能同时对多个端口的外出流量及VLAN的外出流量进行监控,可以对处于关闭状态的端口设置SPAN,但此时的SPAN会话是非活动,但只要相关的接口被打开,SPAN就会变为活动的。监控端口最好是>=受控端口的带宽,否则可能会出现丢包的情况。
SPAN Traffic--SPAN的流量
    使用本地SPAN可以监控所有的网络流量,包括multicast、bridge protocol data unit (BPDU),和CDP、VTP、DTP、STP、PagP、LACP packets. RSPAN不能监控二层协议。
Traffic Types--流量类型
    被监控的流量类型分为三种,Receive (Rx) SPAN 受控端口的接收流量,Transmit (Tx) SPAN 受控端口的发送流量,Both 一个受控端口的接收和发送流量。
Source Port--SPAN会话的源端口(也就是monitored port-即受控端口)
    受控端口可以是实际的物理端口、VLAN、以太通道端口组EtherChannel,物理端口可以在不同的VLAN中,受控端口如果是VLAN则包括此VLAN中的所以物理端口,受控端口如果是以太通道则包括组成此以太通道组的所有物理端口,如果受控端口是一个TRUNK干道端口,则此TRUNK端口上承载的所有VLAN流量都会受到监控,也可以使用filter vlan 参数进行调整,只对filter vlan 中指定的VLAN数据流量做监控。

Destination Port--SPAN会话的目的端口(也就是monitoring port-即监控端口)
    监控端口只能是单独的一个实际物理端口,一个监控端口同时只能在一个SPAN会话中使用,监控端口不参与其它的二层协议如:Layer 2 protocols
Cisco Discovery Protocol (CDP),VLAN Trunk Protocol(VTP),Dynamic Trunking Protocol (DTP),Spanning Tree Protocol (STP),Port Aggregation Protocol (PagP),Link Aggregation Control Protocol (LACP).
缺省情况下监控端口不会转发除SPAN Session以外的任何其它的数据流,也可以通过设置ingress参数,打开监控端口的二层转发功能,比如当连接CISCO IDS的时会有这种需求,此时IDS不仅要接收SPAN Session的数据流,IDS旧碓谕 缰谢够嵊肫渌 璞赣型ㄑ读髁浚  嗫囟丝诘?
二层转发功能。

Reflector Port--反射端口 空气喷嘴
    反射端口只在RSPAN中使用,与RSPAN中的受控端口在同一台交换机上,是用来将本地的受控端口流量转发到RSPAN中在另一台交换机上的远程监控端口的方法,反射端口也只能是一个实际的物理端口,它不属于任何VLAN(It is invisible to all VLANs.)。RSPAN中还要使用一个专用的VLAN来转发流量,反射端口会使用这个专用VLAN将数据流通过TRUNK端口发送给其它的交换机,远程交换机再通过此专用VLAN将数据流发送到监控端口上的分析仪。关于RSPAN VLAN的创建,所有参与RSPAN的交换机应在同一个VTP域中,不能用VLAN 1,也不能用1002-1005,这是保留的(reserved for Token Ring and FDDI VLANs),如果是2-1001的标准VLAN,则只要在VTP Server上创建即可,其它的交换机会自动学到,如果是1006-4094的扩展VLAN,则需要在所有交换机上创建此专用VLAN.
反射端口最好是>=受控端口的带宽,否则可能会出现丢包的情况。
VLAN-Based SPAN--基于VLAN的SPAN
     基于VLAN的SPAN只能监控VLAN中所有活动端口接收的流量(only received (Rx) traffic),如果监控端口属于此VLAN,则此端口不在监控范围内,VSPAN只监控进入交换机的流量,不对VLAN接口上的路由数据做监控。
(VSPAN only monitors traffic that enters the switch, not traffic that is routed between VLANs. For example, if a VLAN is being Rx-monitored and the multilayer switch routes traffic from another VLAN to the monitored VLAN, that traffic is not monitored and is not received on the SPAN destination port. )
1.3.3  SPAN和RSPAN与其它特性的互操作性
Routing--SPAN不监控VLAN间的路由数据;(不好理解)
Routing—Ingress SPAN does not monitor routed traffic. VSPAN only monitors traffic that enters the switch, not traffic that is routed between VLANs. For example, if a VLAN is being Rx-monitored and the multilayer switch routes traffic from another VLAN to the monitored VLAN, that traffic is not monitored and not received on the SPAN destination port.
STP--监控端口和反射端口不会参与STP,但SPAN对受控端口的STP没有影响;
CDP--监控端口不参与CDP;
VTP--RSPAN VLAN可以被修剪pruning;
VLAN and trunking--可以修改受控端口、监控端口和反射端口的VLAN和TRUNK设置,受控端口的改变会立即生效,而监控端口和反射端口则要在从SPAN中去除后才会生效;
EtherChannel--整个以太通道组可以做为受控端口使用,如果一个属于某个以太通道组的物理端口被配成了受控端口、监控端口或反射端口,则此端口会自动从以太通道组去除,当SPAN删除后,它又会自动加入原以太通道组;
QoS--由于受QoS的策略影响,监控端口上收到的数据流会与受控端口实际的数据流不同,比如DSCP值被修改等;
Multicast--SPAN可以监控组播的数据流;
Port security--安全端口不能做为监控端口使用;
802.1x--受控端口、监控端口和反射端口上可以设置802.1x,但有些限制。


2 各品牌交换机端口镜像配置
2.1 思科系列交换机
CISCO CATALYST交换机分为两种,在CATALYST家族中称监听端口为分析端口(analysis port)。cisco交换机最多支持2组镜像,支持所有端口镜像。
2.1.1  如何在Cisco Catalyst系列交换机上配置镜像(SPAN)端口
Cisco Catalyst系列交换机,IOS软件
在进行网络故障排查、网络数据流量分析的过程中,有时需要对网络节点或骨干交换机的某些端口进-行数据流量监控分析,而在交换机中设置镜像(SPAN)端口,可以对某些可疑端口进行监控,同时又不影响被监控端口的数据交换。SPAN(Switched Port Analyzer)的作用主要是为了给某种网络分析器提供网络数据流。它既可以实现一个VLAN中若干个源端口向一个监控端口镜像数据,也可以从若干个VLAN向一个监控端口镜像数据。SPAN 任务不会影响交换机的正常工作。当一个SPAN任务被建立后,根据交换机所处的不同的状态或操作,任务会处于激活或非激活状态,同时系统会将其记入日志。通过“show monitor session”命令可显示SPAN的当前状态。
SPAN数据流主要分为三类:
(1)输入数据流(Ingress SPAN):指被源端口接收进来,其数据副本发送至监控端口的数据流;
(2)输出数据流(Egress SPAN):指从源端口发送出去,其数据副本发送至监控端口的数据流;
(3)双向数据流(Both SPAN):即为以上两种的综合。
在配置SPAN任务时应遵循以下原则:
(1)对数据进行监控分析的设备应搭接在监控端口上;
(2)冗余链路端口只能作为SPAN任务的源端口;
(3)SPAN任务中所有的源端口的被监控方向必须一致;
(4)在设置端口为源端口时,如果没有指定数据流的监控方向,默认为双向;
(5)当SPAN任务含有多个源端口时,这些端口可以来自不同的VLAN;
(6)取消某一个SPAN任务的命令是:no monitor session任务号;
(7)取消所有SPAN任务的命令是:no monitor;
(8)SPAN任务的目的端口不能参与到生成树的距离计算中,但由于源端口的BPDU包可以被镜像,所以SPAN目的端口可以监控到来自源端口的BPDU数据包。
配置SPAN的源端口,命令格式如下:
Switch(config)#[no]monitorsession
{source(interface type/num)|{vlan vlan_ID}}[,|-|rx|tx| both]
以下例子显示如何配置源端口为FastEthernet 5/l的SPAN任务,其监控对象为双向数据流:
Switch(config)# monitor session 1 source interface fastethrnet 5/l
配置SPAN的目的端口,命令格式如下:
Switch(config)# [no] monitor session(session_number){destination{interface type/num}}
以下例子显示如何配置目的端口为FastEthernet 5/48的SPAN任务:
Switch(config)#monitor session l destination interface fastethernet 5/48
当SPAN任务的源端口为Trunk端口时,命令格式如下:
Switch(config)#[no]monitor session{filter vlan [,|-]}
以下例子是当源端口为Trunk端口时,如何配置监控其中的VLANl~VLAN5和 VLAN9:
Switch(config)# monitor session 2 filter vlan 1-5,9
以下是一个综合例子,将用到前面所提到的各种命令:
监控Trunk端口FastEtheraet4/10上的双向数据流(在该端口上承载着VLANl~ VLANl005的数据流),只监控其中VLAN57中的数据流,端口
FastEthernet4/15为目的端口,具体配置方法如下:
Switch(config)# monitor session 1 source interface fastethernet 4/10
Switch(config)# monitor session 1 filter vlan 57
Switch(config)# monitor session 1 destination interface fastethernet 4/15
如果想释放该SPAN任务,输入如下命令:
Switch(config)# no monitor session 1
以下语句显示如何检验SPAN任务的配置结果:
Switch# show monitor session 2
在配置镜像端口(SPAN)过程中,还应考虑到数据流量过大时,设备的处理速度及端口数据缓存的大小,要尽量减少被监控数据包的丢失。

2.1.2  Catalyst 2900XL/3500XL/2950系列交换机端口监听配置(基于CLI)
以下命令配置端口监听:
port monitor
例如,F0/1和F0/2、F0/5同属VLAN1,F0/1监听F0/2、F0/5端口:
interface FastEthernet0/1
port monitor FastEthernet0/2
port monitor FastEthernet0/5
port monitor VLAN1
2.1.3  Catalyst 4000/5000/6000系列交换机端口监听配置(基于IOS)
以下命令配置端口监听:
set span
例如,模块6中端口1和端口2同属VLAN1,端口3在VLAN2,端口4和5在VLAN2,端口2监听端口1和3、4、5,
set span 6/1,6/3-5 6/2
2.1.4  Cisco catylist2820
有2个菜单选项
先进入menu选项,enable port monitor
进入cli模式,
en
conf term
interface fast0/x 镜像口
port monitor fast0/x 被镜像口
exit
wr
2.1.5  Cisco catylist2924、2948 Cisco catylist 3524、3548
Switch>En
Switch#Conf term
Switch(config)#Interface fast mod/port
Switch(config-if)#Port monitor mod/port
Switch(config-if)#Exit
Switch(config)#Wr

2.1.6  Cisco catylist 2550 Cisco catylist 3550no monitor session 1
Switch(config)# no monitor session 1
Switch(config)# monitor session 1 source interface gigabitEthernet1/1 both
Switch(config)# monitor session 1 destination interface gigabitEthernet 1/8
Switch(config)# end
Switch# show monitor session 1

支持2组monitor session
en password
config term
Switch(config)#monitor session 1 destination interface fast0/4(1为session id,id范围为1-2)
Switch(config)#monitor session 1 source interface fast0/1 , fast0/2 , fast0/3 (空格,逗号,空格)
Switch(config)#exit
Switch#copy running-conf startup-conf
Switch#show port-monitor
2.1.7  Cisco catylist 4000/5000系列 Cisco catylist 6000 系列
支持2组镜像
En
Show module (确认端口所在的模块)
Set span source(mod/port) destination(mod/port) in|out|both inpkts enable
Write tern all
Show span
注:多个source:mod/port,mod/port-mod/port 连续端口用横杆“-”,非连续端口用逗号“,”
set span enable //允许镜像
set span disable //禁止镜像
set span source|destination in|out|both inpkts enable create (create用于建立第二组镜像)

2.1.8  Cat2950/3550/3750
3550(config)#monitor session 1 source interface f0/1 - 3 rx 
//指定SPAN session组号为1,源端口为f0/1-f0/3,对进这三个端口的流量
//rx-->指明是进端口得流量,tx-->出端口得流量 both 进出得流量
3550(config)#monitor session 1 destination interface f0/4
//指定监视端口为f0/4
Switch(config)#monitor session 1 destination interface fast0/4
//1为session id,id范围为1-2
Switch(config)#monitor session 1 source interface fast0/1 , fast0/2 , fast0/3
//注意:中间格式为 空格,逗号,空格
Switch(config)#exit
Switch#copy running-conf startup-conf
Switch#show port-monitor
c3550(config)#monitor session 1 source ?
   interface SPAN source interface
   remote SPAN source Remote
   vlan SPAN source VLAN
c3550(config)#monitor session 1 source interface fa0/1 - 3 rx
c3550(config)#monitor session 1 destination interface fa0/24
//Only an Rx SPAN session can have multiple source ports. Note the spaces in syntax when specifying multiple interfaces. Can be “–” or “,”  With Source VLAN's
c3550(config)#monitor session 1 source vlan 1 - 10 rx
c3550(config)#monitor session 1 destination interface fa0/24
TCP Resets
c3550(config)#monitor session 1 source vlan 1 - 10 rx
c3550(config)#monitor session 1 destination interface fa0/24 ingress vlan 1
The Catalyst 2950/3550 will allow you to configure a single VLAN to receive untagged TCP Reset packets. TCP Reset support is configured through the “ingress vlan” keywords. Only one VLAN is permitted. In this example, non-802.1q-tagged TCP Resets to servers or attackers existing on or through VLAN 1 would be allowed, but not if the attack or target was on VLAN 2-10. If the RST is a response to an attack detected by IDS 4.x where the 802.1q tag has been maintained, the RST will be sent on the appropriate VLAN.
If you are monitoring a VLAN trunk port, you may wish to filter one or more of the VLANs on that trunk. This example only monitors VLANs 5 and 100-200 on the trunk.
c3550(config)#monitor session 1 source interface gigabit0/1
c3550(config)#monitor session 1 filter vlan 5 , 100 - 200
c3550(config)#monitor session 1 destination interface fa0/24
If the monitor session destination port is a trunk, you should also use keyword ‘encapsulation dot1q’. If you do not, packets will be sent on the interface in native format.
2.1.9  SPAN和RSPAN的配置举例

SPAN的限制和缺省设置
Catalyst 3550交换机上最多只能设置两个SPAN Session,缺省SPAN没有使用,如果做了设置,缺省情况下,第一个被设为受控端口的接口进出流量都会受到监控,以后再追加的受控端口只会对接收的流量进行监控,监控端口的默认封装类型为Native,也就是没有打VLAN的标记。
1、Configuring SPAN--配置本地SPAN

Switch(config)# no monitor session 1 //先清除可能已经存在SPAN设置
Switch(config)# monitor session 1 source interface fastethernet0/10
//设定SPAN的受控端口
Switch(config)# monitor session 1 destination interface fastethernet0/20
//设定SPAN的监控端口

Switch#sh mon
Session 1
---------
Type : Local Session
Source Ports :
Both : Fa0/10 //注意此处是Both
Destination Ports : Fa0/20
Encapsulation : Native
Ingress: Disabled

Switch(config)# monitor session 1 source interface fastethernet0/11 - 13
//添加SPAN的受控端口

Switch#sh mon
Session 1
---------
Type : Local Session
Source Ports :
RX Only : Fa0/11-13 //注意此处是RX Only
Both : Fa0/10 //注意此处还是Both
Destination Ports : Fa0/20
Encapsulation : Native
Ingress: Disabled

Switch(config)# monitor session 1 destination interface fastethernet0/20 ingress vlan 5
//设定SPAN的监控端口并启用二层转发

Switch#sh mon
Session 1
---------
Type : Local Session
Source Ports :
RX Only : Fa0/11-13
Both : Fa0/10
Destination Ports : Fa0/20
Encapsulation : Native
Ingress: Enabled, default VLAN = 5 //允许正常的流量进入
Ingress encapsulation: Native


2、VLAN-Based SPAN--基于VLAN的SPAN

Switch(config)# no monitor session 2
Switch(config)# monitor session 2 source vlan 101 - 102 rx
Switch(config)# monitor session 2 destination interface fastethernet0/30
Switch#sh mon ses 2
Session 2
---------
Type : Local Session
Source VLANs :
RX Only : 101-102 //注意此处是RX Only
Destination Ports : Fa0/30
Encapsulation : Native
Ingress: Disabled

Switch(config)# monitor session 2 source vlan 201 - 202 rx
Switch#sh mo se 2
Session 2
---------
Type : Local Session
Source VLANs :
RX Only : 101-102,201-202 //注意此处多了201-202
Destination Ports : Fa0/30
Encapsulation : Native
Ingress: Disabled


3、Specifying VLANs to Filter

Switch(config)# no monitor session 2
Switch(config)# monitor session 2 source interface fastethernet0/48 rx
Switch(config)# monitor session 2 filter vlan 100 - 102 //指定受控的VLAN范围
Switch(config)# monitor session 2 destination interface fastethernet0/30

Switch#sh mon ses 2
Session 2
---------
Type : Local Session
Source Ports :
Both : Fa0/48
Destination Ports : Fa0/30
Encapsulation : Native
Ingress: Disabled
Filter VLANs : 100-102 //只监控VLAN100-102中的流量


4、Configuring RSPAN--配置远程RSPAN

RSPAN的Session分成RSPAN Source Session和RSPAN Destination Session两部分,所以
相应的配置也要分别在Session的源和目的交换机上做。


4.1、首先要配置专用的RSPAN VLAN
Switch(config)# vlan 800
Switch(config-vlan)# remote-span
Switch(config-vlan)# end

sw1#sh vl id 800
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
800 VLAN0800 active Fa0/47, Fa0/48

VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
800 enet 100800 1500 - - - - - 0 0

Remote SPAN VLAN
----------------
Enabled //注意看此处的提示

Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------


4.2、配置RSPAN Source Session

Switch(config)# no monitor session 1
Switch(config)# monitor session 1 source interface fastethernet0/10 - 13
Switch(config)# monitor session 1 source interface fastethernet0/15 rx
Switch(config)# monitor session 1 destination remote vlan 800 reflector-port fastethernet0/20

sw1#sh mo se 1
Session 1
---------
Type : Remote Source Session
Source Ports :
RX Only : Fa0/11-13,Fa0/15
Both : Fa0/10
Reflector Port : Fa0/20
Dest RSPAN VLAN : 800


4.3、配置RSPAN Destination Session

Switch(config)# monitor session 1 source remote vlan 800
Switch(config)# monitor session 1 destination interface fastethernet0/30
Switch(config)# end

sw2#sh mo se 1
Session 1
---------
Type : Remote Destination Session
Source RSPAN VLAN : 800
Destination Ports : Fa0/30
Encapsulation : Native
Ingress: Disabled


(VLAN-Based RSPAN)基于VLAN的RSPAN也和上面的方法类似,只不过受控的是整个VLAN.
启用监控端口的二层转发以及Specifying VLANs to Filter 的方法也和本地SPAN相同,
此处不再举例。详见CISCO CD.


五、Catalyst 4000/4500系列交换机的SPAN配置

Configuring SPAN
命令如下:
set span {src_mod/src_ports | src_vlan | sc0} dest_mod/dest_port [rx | tx | both]
[inpkts {enable | disable}] [learning {enable | disable}]
[multicast {enable | disable}] [create]
set span中的create参数用于创建多个SPAN Session.
show span
set span disable [dest_mod/dest_port | all]

举例:
This example shows how to configure SPAN so that both the transmit and receive
traffic from port 2/4 (the SPAN source) is mirrored on port 3/6 (the SPAN destination):

Console> (enable) set span 2/4 3/6
// Overwrote Port 3/6 to monitor transmit/receive traffic of Port 2/4
Incoming Packets disabled. Learning enabled.

Console> (enable) show span
Destination : Port 3/6
Admin Source : Port 2/4
Oper Source : None
Direction : transmit/receive
Incoming Packets: disabled
Learning : enabled
Filter : -
Status : active
----------------------------------------------
Total local span sessions: 1
Console> (enable)

This example shows how to set VLAN 522 as the SPAN source and port 2/1 as the SPAN destination:

Console> (enable) set span 522 2/1
// Overwrote Port 2/1 to monitor transmit/receive traffic of VLAN 522
Incoming Packets disabled. Learning enabled.
Console> (enable) show span
Destination : Port 2/1
Admin Source : VLAN 522
Oper Source : Port 2/1-2
Direction : transmit/receive
Incoming Packets: disabled
Learning : enabled
Filter : -
Status : active
----------------------------------------------
Total local span sessions: 1
Console> (enable)


Configuring RSPAN
命令如下:
set vlan vlan_num [rspan]
show vlan
set rspan source { | } {rspan_vlan} reflector mod/port [rx | tx | both]
[] [create]
set rspan destination {mod_num/port_num} {rspan_vlan} [inpkts {enable | disable}]
[learning {enable | disable}] [create]
show rspan
set rspan disable source [rspan_vlan | all]
set rspan disable destination [mod_num/port_num | all]









2.2  H3C系列交换
2.2.1  S7500支持的镜像
表1-2 S7500系列交换机支持的镜像功能及相关命令
功能        规格        相关命令        详细配置
镜像        支持端口镜像        mirroring-group
mirroring-group mirroring-port
mirroring-group monitor-port
monitor-port
mirroring-port        1.3.1 

        支持远程端口镜像        mirroring-group
mirroring-group mirroring-port
mirroring-group monitor-port
mirroring-group reflector-port
mirroring-group remote-probe vlan
remote-probe vlan enable        1.3.2   

        支持流镜像        monitor-port
mirrored-to        1.3.3   

        支持远程流镜像        mirroring-group
mirroring-group monitor-port
mirroring-group reflector-port
mirroring-group remote-probe vlan
remote-probe vlan enable
mirrored-to inbound acl-rule [ system-index ] { interface interface-type interface-number reflector | mirroring-group group-id }        1.3.4 

2.2.1. 配置本地端口镜像
1.配置准备
            镜像源端口为GigabitEthernet 2/0/1,对端口接收和发送的报文都进行镜像
        镜像目的端口为GigabitEthernet 2/0/4
2.配置举例
配置1:
<H3C> system-view
[H3C] mirroring-group 1 local
[H3C] interface GigabitEthernet 2/0/4
[H3C-GigabitEthernet2/0/4] mirroring-group 1 monitor-port
[H3C-GigabitEthernet2/0/4] quit
[H3C] interface GigabitEthernet 2/0/1
[H3C-GigabitEthernet2/0/1] mirroring-group 1 mirroring-port both
配置2:
<H3C> system-view
[H3C] mirroring-group 1 local
[H3C] mirroring-group 1 monitor-port GigabitEthernet 2/0/4
[H3C] mirroring-group 1 mirroring-port GigabitEthernet 2/0/1 both
2.2.2  配置远程端口镜像
1. 配置准备
              确定了源交换机、中间交换机、目的交换机
              确定了镜像源端口、反射端口、镜像目的端口、Remote-probe VLAN
              通过配置保证了Remote-probe VLAN内从源交换机到目的交换机的二层互通性
              确定了被监控报文的方向
              启动了Remote-probe VLAN
  说明:
      如果用户想镜像tagged报文,则需要在反射口上配置VLAN VPN。
      反射端口无法作为正常的端口转发流量,所以建议用户将没有使用的处于DOWN状态的端口配置为反射端口,且不要在该端口上添加其它配置。
      不要在与中间交换机或目的交换机相连的端口上配置镜像源端口,否则可能引起网络内的流量混乱。
2. 配置举例
组网需求:
              Switch A通过GigabitEthernet 2/0/2和数据检测设备相连
              Switch A的Trunk端口GigabitEthernet 2/0/1和Switch B的Trunk端口GigabitEthernet 2/0/1相连
              Switch B的Trunk端口GigabitEthernet 2/0/2和Switch C的Trunk端口GigabitEthernet 2/0/1相连
              Switch C的端口GigabitEthernet 2/0/2和PC1相连
需求为通过数据检测设备对PC1发送的报文进行监控和分析。
使用远程端口镜像功能实现该需求,进行如下配置。
              定义VLAN 10为Remote-probe VLAN;
              Switch A为目的交换机,连接数据监控设备的端口GigabitEthernet 2/0/2为镜像目的端口。GigabitEthernet 2/0/2必须为Access端口,并且不能使能STP及LACP。
              Switch B为中间交换机
              Switch C为源交换机,GigabitEthernet 2/0/2为镜像源端口,定义GigabitEthernet 2/0/3为反射端口。GigabitEthernet 2/0/3必须为Access端口,并且不能使能STP及LACP。
组网图:

图1-3 远程端口镜像组网示意图
配置步骤:
# Switch C的配置
<H3C> system-view
[H3C] vlan 10
[H3C-vlan10] remote-probe vlan enable
[H3C-vlan10] quit
[H3C] interface GigabitEthernet 2/0/1
[H3C-GigabitEthernet2/0/1] port link-type trunk
[H3C-GigabitEthernet2/0/1] port trunk permit vlan 10
[H3C-GigabitEthernet2/0/1] quit
[H3C] mirroring-group 1 remote-source
[H3C] mirroring-group 1 mirroring-port GigabitEthernet 2/0/2 inbound
[H3C] mirroring-group 1 reflector-port GigabitEthernet 2/0/3
[H3C] mirroring-group 1 remote-probe vlan 10
自动干手器[H3C] display mirroring-group remote-source
mirroring-group 1:
    type: remote-source
    status: active
    mirroring port:
        GigabitEthernet2/0/2  inbound
    reflector port: GigabitEthernet2/0/3
    remote-probe vlan: 10
# Switch B的配置
<H3C> system-view
[H3C] vlan 10
[H3C-vlan10] remote-probe vlan enable
[H3C-vlan10] quit
[H3C] interface GigabitEthernet 2/0/1
[H3C-GigabitEthernet2/0/1] port link-type trunk
[H3C-GigabitEthernet2/0/1] port trunk permit vlan 10
[H3C-GigabitEthernet2/0/1] quit
[H3C] interface GigabitEthernet 2/0/2
[H3C-GigabitEthernet2/0/2] port link-type trunk
[H3C-GigabitEthernet2/0/2] port trunk permit vlan 10
# Switch A的配置
<H3C> system-view
[H3C] vlan 10
[H3C-vlan10] remote-probe vlan enable
[H3C-vlan10] quit
[H3C] interface GigabitEthernet 2/0/1
[H3C-GigabitEthernet2/0/1] port link-type trunk
[H3C-GigabitEthernet2/0/1] port trunk permit vlan 10
[H3C-GigabitEthernet2/0/1] quit
[H3C] mirroring-group 1 remote-destination
[H3C] mirroring-group 1 monitor-port GigabitEthernet 2/0/2
[H3C] mirroring-group 1 remote-probe vlan 10
[H3C] display mirroring-group remote-destination
mirroring-group 1:
    type: remote-destination
    status: active
    monitor port: GigabitEthernet2/0/2
    remote-probe vlan: 10
2.2.3  配置流镜像
1. 配置准备
              定义了进行流识别的ACL。关于定义ACL的描述请参见“ACL”模块
              确定了镜像目的端口
              确定需要进行流镜像配置的端口和被镜像流的方向
 
2. 配置举例
组网需求:
押花材料              交换机的GigabitEthernet 2/0/1接入了10.1.1.1/24网段
              镜像来自10.1.1.1/24网段的报文到镜像目的端口GigabitEthernet 2/0/4
配置步骤:
<H3C> system-view
[H3C] acl number 2000
[H3C-acl-basic-2000] rule permit source 10.1.1.1 0.0.0.255
[H3C-acl-basic-2000] rule deny source any
[H3C-acl-basic-2000] quit
[H3C] mirroring-group 3 local
[H3C] mirroring-group 3 monitor-port GigabitEthernet 2/0/4
[H3C] interface GigabitEthernet 2/0/1
[H3C-GigabitEthernet2/0/1] qos
[H3C-qosb-GigabitEthernet2/0/1] mirrored-to inbound ip-group 2000 interface GigabitEthernet 2/0/4
2.2.4  配置远程流镜像
1. 配置准备
              定义了进行流识别的ACL。关于定义ACL的描述请参见“ACL”模块
              确定了源交换机、中间交换机、目的交换机
              确定了反射端口、镜像目的端口、Remote-probe VLAN
              通过配置保证了Remote-probe VLAN内从源交换机到目的交换机的二层互通性
              确定了被监控报文的方向
              启动了Remote-probe VLAN
  说明:
      如果用户想镜像tagged报文,则需要在反射口上配置VLAN VPN。
      反射端口无法作为正常的端口转发流量,所以建议用户将没有使用的处于DOWN状态的端口配置为反射端口,且不要在该端口上添加其它配置。

2. 配置举例
组网需求:
        Switch A通过GigabitEthernet 2/0/2和数据检测设备相连
        Switch A的Trunk端口GigabitEthernet 2/0/1和Switch B的Trunk端口GigabitEthernet 2/0/1相连
        Switch B的Trunk端口GigabitEthernet 2/0/2和Switch C的Trunk端口GigabitEthernet 2/0/1相连
        Switch C的端口GigabitEthernet 2/0/2接入了10.1.1.1/24网段
使用远程流镜像功能把来自10.1.1.1/24网段的报文镜像到Switch A的GigabitEthernet 2/0/2以便数据检测设备监控流量:
        定义VLAN 10为Remote-probe VLAN
        Switch A为目的交换机,连接数据监控设备的端口GigabitEthernet 2/0/2为镜像目的端口。GigabitEthernet 2/0/2必须为Access端口,并且不能使能STP及LACP
        Switch B为中间交换机
        Switch C为源交换机,定义GigabitEthernet 2/0/3为反射端口。GigabitEthernet 2/0/3必须为Access端口,并且不能使能STP及LACP。在端口GigabitEthernet 2/0/2配置流镜像功能
组网图:

图1-4 远程流镜像组网示意图
配置步骤:
# Switch A的配置
<H3C> system-view
[H3C] vlan 10
[H3C-vlan10] remote-probe vlan enable
[H3C-vlan10] quit
[H3C] interface GigabitEthernet 2/0/1
[H3C-GigabitEthernet2/0/1] port link-type trunk
[H3C-GigabitEthernet2/0/1] port trunk permit vlan 10
[H3C-GigabitEthernet2/0/1] quit
[H3C] mirroring-group 1 remote-destination
糖浆罐[H3C] mirroring-group 1 monitor-port GigabitEthernet 2/0/2
[H3C] mirroring-group 1 remote-probe vlan 10
[H3C] display mirroring-group remote-destination
mirroring-group 1:
    type: remote-destination
    status: active
    monitor port: GigabitEthernet2/0/2
    remote-probe vlan: 10
# Switch B的配置
<H3C> system-view
[H3C] vlan 10
[H3C-vlan10] remote-probe vlan enable
[H3C-vlan10] quit
[H3C] interface GigabitEthernet 2/0/1
[H3C-GigabitEthernet2/0/1] port link-type trunk
[H3C-GigabitEthernet2/0/1] port trunk permit vlan 10
[H3C-GigabitEthernet2/0/1] quit
[H3C] interface GigabitEthernet 2/0/2
[H3C-GigabitEthernet2/0/2] port link-type trunk
[H3C-GigabitEthernet2/0/2] port trunk permit vlan 10
# Switch C的配置
<H3C> system-view
[H3C] acl number 2000
[H3C-acl-basic-2000] rule permit source 10.1.1.1 0.0.0.255
[H3C-acl-basic-2000] rule deny source any
[H3C-acl-basic-2000] quit
[H3C] vlan 10
[H3C-vlan10] remote-probe vlan enable
[H3C-vlan10] quit
[H3C] interface GigabitEthernet 2/0/1
[H3C-GigabitEthernet2/0/1] port link-type trunk
[H3C-GigabitEthernet2/0/1] port trunk permit vlan 10
[H3C-GigabitEthernet2/0/1] quit
[H3C] mirroring-group 1 remote-source
[H3C] mirroring-group 1 reflector-port GigabitEthernet 2/0/3
[H3C] mirroring-group 1 remote-probe vlan 10
[H3C] interface GigabitEthernet 2/0/2
[H3C-GigabitEthernet2/0/2] qos
[H3C-qosb-GigabitEthernet2/0/2] mirrored-to inbound ip-group 2000 interface GigabitEthernet 2/0/3 reflector
[H3C-qosb-GigabitEthernet2/0/2] display qos-interface GigabitEthernet2/0/2 mirrored-to
GigabitEthernet2/0/2: mirrored-to
Inbound:
   Matches: Acl 2000 rule 0  running
     Mirrored to: mirroring-group 1

2.3  北电交换机系列
2.3.1  Nortel 1100、2000
支持一组镜像,2个source和1个destination
默认用户名/密码: 12/12
config
mirror
input1 (mod/port) enable
input2 (mod/port) enable
output (mod/port) enable
save configure ture
2.3.2  Nortel 8000 series 端口监听配置
Software 3.2.0.0以前的版本,支持一组镜像,10个source,一个destination
Software 3.2.0.0后的版本,支持2组镜像,(说明:通常8个ethernet口为一个电路集成板,destination不可以在同一个板子上,即1-8口上只允许有一个destination),支持25个source(10个有效―――不懂,没有玩过这么高的版本)。
用户名/密码:rwa/rwa 超级用户
例如:2/6 2/6 2/8 镜像到2/1
config diag mirror-by-port 1 create in-port 2/4 out-port 2/1 (1是id号,范围1-10)
config diag mirror-by-port 1 enable ture
config diag mirror-by-port 2 create in-port 2/6 out-port 2/1
config diag mirror-by-port 2 enable ture
config diag mirror-by-port 3 create in-port 2/8 out-port 2/1
config diag mirror-by-port 3 enable ture
config diag mirror-by-port 1 mode both|tx|rx
save config
diag mirror-by-port id info (查看第id号镜像信息)
Nortel 交换机提供的镜像功能通常是rx的,不支持both方式(看cpu而定),所以ping包检测不到,只能检测到ping回答
配置格式
config diag mirror-by-port <id> create in-port <value> out-port <value>
config diag mirror-by-port <id> enable <true|false>
config diag mirror-by-port <id> delete
config diag mirror-by-port <id> info
config diag mirror-by-port <id> mirrored-port <ports>
config diag mirror-by-port <id> mirroring-port <ports>
config diag mirror-by-port <id> mode <tx|rx|both>
2.3.3  北电8600
create in-port 1/1 out-port 1/2
mode both/rx/tx
+++++++牛比的分割线+++++++
WEG 模式登陆配置
用device manager菜单
EDIt--Diagnostics--PortMirrors
在DEVICE MANAGER上打开EDIT菜单,
到DIAGNOSTICS项,单击打开选PORT MIRRORS项,进行相应的配置即可
2.4  3COM交换机端口监听配置实例
在3COM交换机中,端口监听被称为“Roving Analysis”。网络流量被监听的端口称作“监听口”(Monitor Port),连接监听设备的端口称作“分析口”(Analyzer Port)。
以下命令配置端口监听:
● 指定分析口
feature rovingAnalysis add,或缩写 f r a,
例如:
Select menu option: feature rovingAnalysis add
Select analysis slot: 1
Select analysis port: 2
● 指定监听口并启动端口监听 湿度传感器芯片
feature rovingAnalysis start,或缩写 f r sta,
例如:
Select menu option: feature rovingAnalysis start
Select slot to monitor (1-12): 1
Select port to monitor (1-8): 3
● 停止端口监听
feature rovingAnalysis stop,或缩写 f r sto,
● 删除分析口并还原其状态
feature rovingAnalysis remove,或者使用缩写 f r r,
使用此命令之前需执行停止端口监听命令。
● 查看分析口和监听口的设置:
feature rovingAnalysis summary,或者使用缩写 f r su,
例如:
Select menu option: feature rovingAnalysis summary
Monitor port Analysis port State
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Slot 3 Port 5 Slot1 Port2 Enabled
2.4.1  3com 4400
3com 4400支持一对一的端口镜像功能,即将被监控端口(monitor port)收发的数据从监控端口(analyzer)发送出去,使连接到analyzer端口的网络分析设备能对被监控端口的流量及数据进行分析。
举例:24端口的计算机来监控9口的流量。
feature roving
Menu options: --------------3Com SuperStack 3 Switch 4400---------------
add - Configure the roving analysis port
remove - Clear the roving analysis port
start - Start monitoring
stop - Stop monitoring
summary - Display summary information
Select menu option (feature/rovingAnalysis): add
Select analyzer port (unit:port,?): 1:24
Select menu option (feature/rovingAnalysis): start
Select port to monitor (unit:port,?): 1:9
Select menu option (feature/rovingAnalysis): summ
Monitor Port Analyzer Port State
---------------------------------------------
Unit 1 Port 9 Unit 1 Port 24 Enabled
Select menu option (feature/rovingAnalysis):
[说明]
以上例子中,端口24是analyzer端口,接sniffer等流量查询、监控等设备。被监控的是端口9,该端口所有收发的数据都会从端口24发出去。


2.5  Intel交换机端口监听配置实例
Intel称端口监听为“Mirror Ports”。 网络流量被监听的端口称作“源端口”(Source Port),连接监听设备的端口称作“镜像口”(Mirror Port)。
配置端口监听步骤如下:
● 在navigation菜单,点击Statistics下的Mirror Ports,弹出Mirror Ports信息。
● 在Configure Source 列中点击端口来选择源端口,弹出Mirror Ports Configuration。
● 进行源端口设置:
源端口是镜像流量的来源口,镜像口是接收来自源端口流量的端口。
● 点击Apply确定
可以选择三种监听的方式:
1.连续(Always):镜像全部流量。
2.周期(Periodic):在一定周期内镜像全部流量。镜像周期在Sampling Interval configuration中设置。
3.禁止(Disabled):关闭流量镜像。

2.6  Avaya交换机端口监听配置实例
在Avaya交换机用户手册中,端口监听被称为“端口镜像”(Port Mirror)。
以下命令配置端口监听:
{ set|clear } Port Mirror
设置端口侦听:set port mirror source-port mirror-port sampling { always | disable | periodic } [ max-packets-sec < max-packets-sec-value> ] [ piggyback-port ]
禁止端口监听:clear port mirror
命令中,mod-port-range指定端口的范围;mod-port-spec指定特定的端口;piggyback-port指定双向镜像的端口;sampling指定镜像周期;max-packets-sec仅在sampling设置为periodic时使用,指定监听口每秒最多的数据报数量。

2.7         港湾交换机端口镜像
2.7.1  flax24实例
Harbour(config)#
Harbour(config)# config mirroring 1
add Add ports to mirroring group.
delete Delete ports from mirroring group.
disable Disable current mirroring group.
to Apply port mirroring group.
Harbour(config)# config mirroring 1 add port 5  (source)
Harbour(config)# config mirroring 1 to 13    (target)
Harbour(config)# show mirroring
Port Mirror Configurations:
Mirroring Group 1:
Source Port: 5
Target Port: 13
Harbour(config)# save configuration
2.7.2  港湾6802
!Ethernet port config
interface ethernet 1/11
  mirror ingress 1/10 egress 1/10
exit

Extreme alpine 3802
Alpine3804: # enable mirroring to port 2:10
Alpine3804: # configure mirror add port 2:32
Alpine3804: # configure mirror add port 2:1

注意:
比如G产品线的百兆电口在做端口镜像时,如果监控端口与被监控端口不在一个控制器(一组端口)中的话,只能抓到进端口的包,出端口的包抓不到。
μHammer3550-48交换机内部由两块芯片堆叠而成的硬件特点,其中芯片1包括端口1-12、25-36、50,芯片2包括端口13-24、37-48、49,由于mirror不能跨芯片建立,因此建立端口镜像时只能在端口1-12、25-36、50或端口13-24、37-48、49范围内建立。
2.7.3  BigHammer 6808端口镜像
命令 解释

interface ethernet  <slot/port > 进入端口配置模式
mirror {[ingress]  <portlist >}*1 {[egress]  <portlist >}*1 本端口做为镜像的目标端口(mirror to),镜像一组端口的接收(ingress)和镜像另一组端口的发送(egress)
no mirror 设置本端口不做为镜像的目标端口
show 显示端口的配置和状态,包括Mirror的设置


配置案例

  在BH-2GBIC10GTX类型的单板在槽位1,将板的1端口设置为镜像目标端口,镜像端口2的接收,端口3的接收和发送,端口4的发送,配置命令如下:
Harbour(config)#interface ethernet 1/1
Harbour(config-if-eth1/1)#mirror ingress 1/2,1/3 egress 1/3-4

取消端口镜像,端口1做为普通端口使用,配置命令如下:
Harbour(config)#interface ethernet 1/1
Harbour(config-if-eth1/1)#no mirror
2.7.4  NetHammerM128
NetHammerM128的八口交换以太网接口中,每一个接口作为一个以太网设备,支持速率模式、双工模式等的配置。
在很多情况下,并不需要将镜像端口的所有收发报文全部捕捉,这是可以通过设定一系列的过滤条件来控制被捕捉的报文,这样可以更有目的的进行分析。交换模块提供的过滤条件有:接收/发送;源MAC地址/目的MAC地址。
相关命令:config mirror
设置端口镜象
例:将端口2、3接收到的目的地址为00:11:22:33:44:55的报文镜象到端口1上:
router(config-if-swi)# config mirror to 1
router(config-if-swi)# config mirror monitor all add 2-3
router(config-if-swi)# config mirror mode all dest 00:11:22:33:44:55
router(config-if-swi)#

2.8  DELL交换机端口监听配置
在Dell交换机中,端口监听被称为“端口镜像”(Port Mirroring)。使用交换机的管理界面,参数如下:
Destination Port(目的地端口):定义端口通信要镜像到的端口号;
Source Port(源端口):定义被镜像端口的端口号。
Add(添加):添加端口镜像操作。
Type(类型):指定要镜像的端口通信类型。 可能的字段值包括:“RX”-表示镜像进入网络的数据;“TX”-表示镜像流出网络的数据;Both()-表示镜像所有数据。
Status(状态):表示端口的状态。 可能的字段值包括: “Active”-表示端口被启用;“Not Active”-表示端口被禁用。
Remove(删除):删除端口镜像会话。 可能的字段值包括: “已选取”-删除端口镜像会话;“未选取”-保留端口镜像会话。
具体设置:
1、在Port Mirroring对话框中的Destination Port中选中目的端口(镜像端口),再单击Add按钮;
2、在系统将打开“Add Source Port”(添加源端口)页面中,定义“Source Port”(源端口)和“Type”(类型)字段,并单击“Apply Changes”(应用更改), 使系统接收更改。
(注:如果需要从端口镜像会话删除副本端口,请打开“Port Mirroring”(端口镜像)页面,选取“Remove”(删除)复选框,再单击“Apply Changes”(应用更改)。 系统将删除端口镜像会话,并更新设备。)
以下命令配置端口监听:
指定分析口
CLI 命令实例:
Console(config)# interface ethernet 1/e1
Console(config-if)# port monitor 1/e8
Console# show ports monitor
Source port Destination Port Type Status
----------- ---------------- ----- -------
1/e1 1/e8 RX, TX Active
DELL 5224:
   Console#conf
   Console(config)#interface ethernet 1/19
   Console(config-if)#port monitor ethernet 1/7 tx   
   Console#show port moni
   Port Mirroring
   -------------------------------------
   Destination port(listen port):Eth1/19
   Source port(monitored port)  :Eth1/7
   Mode                        :TX
   删除镜像
   Console(config)#interface ethernet 1/19
   Console(config-if)#no port monitor ethernet 1/7
2.9  NetCore交换机端口监听配置
NetCore交换机中,端口监听被称为“端口镜像”(Port Mirroring)。
交换机提供四种监视状态:
Off                关闭Mirror功能
Rx                捕获被监视端口的接收数据
Tx                捕获被监视端口的发送数据
Both                捕获被监视端口的接收和发送的数据
进入NetCore的超级终端,在主菜单中输入“5”进入端口镜像设置界面,输入“1”设置端口镜像状态。
如设置端口1为镜像端口,端口8为被镜像端口,捕获该端口的接收和发送数据。
配置命令如下:
1. 选择配置的选项 (1,off, 2.Rx, 3.Tx, 4.Both) :4
2. 选择捕获端口:1
3. 选择被镜像端口:8
按Esc键退回镜像设置界面,设置成功。
2.10         NETGEAR增强型智能交换机端口镜像功能的设置
NETGEAR增强型智能交换机(FS700TS系列、FS728TP、GS700TS系列、GS700TP系列等)支持标准的端口镜像功能,本文使用GS724TP讲述如何使用1号端口对2、3、4号端口进行监控配置,过程如下:
1、登陆GS724TP交换机管理界面,进入Monitoring-Port Mirroring,设置目标端口、源端口和监控方向。

Destination Port:安装了数据包监控软件的端口。端口格式为:非堆叠交换机(以第一个端口为例)千兆端口为“g1”,百兆端口为“e1”;堆叠交换机(以第一个堆叠单元的第一个端口为例)千兆端口为“1/g1”,百兆端口为“1/e1”。
本例中,g1定义为Destination Port,要注意的是接在该端口的电脑再不可以与交换机进行TCP/IP通讯了,只可以接收被监控的数据。
Source Port:被监控端口,格式同Destination Port。
Type:监控方向
TX Only:被监控端口的发送数据
RX Only:被监控端口的接收数据
TX and RX:被监控端口的双向传输数据
设好后点ADD。
2、继续添加源端口g3和g4


3、如果要修改被监控数据包的方向属性,比如将g2的双向监控改为仅监控出口流量,则选中“g2”前面的勾,然后在Type处选为TX Only,然后点APPLY保存即可。

4、若要将定义的镜像删除:选中Select下的勾(即全选),然后按DELETE即可

注意:一个监控端口可以监控多个被监控端口,但每个交换机(堆叠组)内只能存在一个监控端口,不能有多个监控端口。
2.11  Extreme 交换机
特点:      ●只能创建多对一或者一对一的镜像端口
                 ●可以监听 VLAN 的流量
                ●Extreme 会镜像 IN 和 OUT 的流量。这就意味着在镜像 VLAN 的时候,会看到一个报文至少两次从 VLAN 的某个端口出来,并且进入 VLAN 的另一个端口。
版本高于4.1的 Extreme 交换机端口镜像配置方法
{enable | disable} mirroring on port
     开启/关闭端口镜像功能,并且指定镜像流量从何端口流出,port-no 只能是一个端口
configure mirroring { add | delete } { vlan | port }
     指定镜像哪个或哪些 VLAN 或端口的流量 { vlan | port } 部分可以重复多次
版本低于 4.1 的 Extreme 交换机端口镜像配置方法
   enable mirror to port port-no
     开启端口镜像功能,并且指定镜像流量从何端口流出,port-no 只能是一个端口
   disable mirror
           关闭端口镜像功能
   config mirror add port
           镜像端口 port-no 的流量,如果这个端口包含多个 VLAN 这些流量都会被镜像到目的端口
   config mirror add port vlan
           镜像端口 port-no 中指定 VLAN 的流量
   config mirror add vlan
           镜像端口中指定 VLAN 的所有端口的流量
   config mirror del port
           取消对 port-no 的端口镜像
   config mirror del vlan
           取消对指定 VLAN 的端口镜像
   show mirror
           显示端口镜像情况
2.12  Foundry 交换机
特点:
    可以创建多对多的端口镜像
Foundry 交换机端口镜像配置方法
在配置模式中(Configuration Mode):
interface    port monitor { { rx | tx | both}}
           确定镜像流量从哪个端口流出,修改此端口配置
           指定要镜像哪些端口的哪些流量(rx 指接收的流量,tx 指发送的流量,both 指双向流量),{ { rx | tx | both}} 部分可以重复

2.13  Juniper 交换机
      特点: 
                ●每交换机只能有一个监听端口
                ●只能镜像 IPv4 的流量
                ●只能镜像发送(transit only)的流量,不能镜像接收的流量

Juniper M 系列和 T 系列端口镜像配置方法

      usen@router# show forwarding-options port-    mirroring { input {family inet; rate ; run-    length ;} output interface {next-hop

   ;} no-filter-check;} }

选择将抽样的流量发送到哪个目的端口

user@router# show firewall filter mirror-sample from {...} then {sample; accept;}

定义抽样过滤器,选择感兴趣的流量

user@router# show interface unit 0 family inet filter {input mirror-sample;}

选择将抽样的过滤器应用到某个端口
端口镜像的风险
加重交换机负载,造成设备不稳定
在某些情况下会丢包,不能保证 100% 镜像流量。例如,由于多个源端口镜像到一个目的端口,目的端口无法处理造成丢包
2.14  中兴端口镜像配置
系统允许通过端口镜像功能来监视端口。端口监视功能负责监视系统端口的性能和活动,或者监视某一个单独的端口由ACL指定的业务。在配置模式下,用户可以通过以下的一个简单的命令配置系统端口镜像:
port mirroring monitor-port <port number> target-port<port list>|target-profile <acl name>        配置端口镜像
端口监视可适用于WAN端口。但是不允许基于端口对端口的方式来配置端口监视(只能为整个WAN卡配置端口监视)。只能指定IP ACL进行端口监视。
2.15  凯创交换机端口镜像配置
Ssr8000
SSR Command Line Interface Reference Manual 551
port mirroring
Command
Purpose
Apply port mirroring to one or more target ports on an SSR or to traffic specified by an
ACL profile.
Format
port mirroring monitor-port target-port |target-profile name>
Mode
Configure
Description
The port mirroring command allows you to monitor via a single port the activity of one
or more ports on an SSR or the traffic that is specified by an ACL.
Parameters
monitor-port
The port you will use to monitor activity.
target-port
The port(s) for which you want to monitor activity. You can specify a single port or a
comma-separated list of ports.
target-profile
The name of the ACL that specifies the profile of the traffic that you want to
monitor. The ACL must be a previously created IP ACL. The ACL may contain
either permit or deny keywords. The port mirroring command only looks at the
following ACL rule parameter values: protocol, source IP address, destination IP
address, source port, destination port, and TOS.
2.16  华为系列交换机
2.16.1   华为NE80端口镜像配置
NE80支持端口镜像功能,可以将系统中某个端口的流量镜像到其它的端口。
出端口的报文和入端口的报文必须分别镜像到不同的端口。NE80已可以做到POS 622,POS 155,GE、FE到GE、FE的镜像。
配置内容包括:配置端口为镜像端口、配置被镜像端口到镜像端口的映射关系。
例将ethernet 3/0/2的入端口流量和出端口流量分别镜像到ethernet 3/0/0和3/0/1,仅需两条配置:
NE80-C(config)#observing-port ethernet3/0/0    //3/0/0为镜像端口
NE80-C(config)#observing-port ethernet3/0/1    //3/0/1为镜像端口   
NE80-C(config)#port-mirroring ethernet3/0/2 both ethernet3/0/0 ethernet3/0/1
//3/0/2为被镜像端口,3/0/0镜像3/0/2的入流量,3/0/1镜像3/0/2的出流量。
如果只想镜像出端口流量或入端口流量,可以将both 改为egress 或 ingress.然后就可在镜像端口通过各种测试工具进行分析。
2.16.2  Quidway 3026端口镜像配置方法:
以下例子中,镜像端口为e0/18,被镜像端口为e0/3,输入如下命令配置镜像:
?        配置镜像端口:
Quidway(config)#monitor-port e 0/18(e0/18作为镜像端口)
?        配置被镜像端口:
Quidway(config)#monitor e 0/3(e0/3 为被镜像端口)
?        上述两条命令与以下一条命令等效:
Quidway(config)#monitor e 0/3 observing-port e0/18
?        查看镜像端口信息:
Quidway#show  monitor(察看镜像端口信息)
Information about monitor port(s)
The observing port : Ethernet0/18
The monitored ports:   Ethernet0/3
以上端口镜像配置方法适用于Quidway2008/2016/3026/2403H交换机。
2.16.3  Quidway 3526端口镜像配置方法:
3526交换机提供基于流规则的镜像,配置方法与Quidway 3026不同。以下例子中,镜像端口e0/24,被镜像端口e0/1:
?        首先定义用来监控的端口:
Quidway(config)#monitor-port Ethernet 0/24,定义用0/24口做为监控端口;
?        定义流分类规则:
因为3526交换机提供基于流规则的镜像,因此要定义流分类规则(若要监控Ethernet0/1的双向业务流则需配置下面两条流分类命令,若只需监控单方向的业务流选择其中之一即可):
将从Ethernet0/1输出的业务流镜像到监控端口:
Quidway(config)#rule-map l2 rule1 ingress Ethernet 0/1 egress any,
其中rule1是自定义的rule名字,any是定义对端口Ethernet0/1的所有出业务流进行监控;
将从Ethernet0/1输入的业务流镜像到监控端口:
Quidway(config)#rule-map l2 rule2 ingress any egress Ethernet 0/1,
其中any是定义对端口Ethernet0/1的所有入业务流进行监控。
注:两个规则不可同名,否则后配的规则会覆盖先配的规则;
ingress、egress流量方向如图一所示。                             
?        定义流的动作:
对流的动作预先定义好,以便在访问控制列表的定义中引用。
Quidway(config)#flow-action huawei monitor-port,其中huaweiwei为flow-action自定义的名字,monitor-port为定义镜像功能。
?        定义访问控制列表ACL:
Quidway(config)#acl acl1 rule1 huawei,其中acl1为自定义的acl名字,同时定义访问控制列表acl1引用的流分类规则是rule1,引用的流规则是huawei。
?        激活ACL配置项:
Quidway(config)#access-group acl1。
2.16.4  华为其他
一、说明
『环境配置参数』
      1. PC1接在交换机E0/1端口,IP地址1.1.1.1/24
      2. PC2接在交换机 E0/2端口,IP地址2.2.2.2/24
      3. E0/24为交换机上行端口
      4. Server接在交换机E0/8端口,该端口作为镜像端口
『组网需求』
      1. 通过交换机端口镜像的功能使用server对两台pc的业务报文进行监控。
      2. 按照镜像的不同方式进行配置:
               1)  基于端口的镜像
               2)  基于流的镜像
二、 数据配置步骤『端口镜像的数据流程』
    基于端口的镜像是把被镜像端口的进出数据报文完全拷贝一份到镜像端口,这样来进行流量观测或者故障定位。
【3026等交换机镜像】

S2008/S2016/S2026/S2403H/S3026等交换机支持的都是基于端口的镜像,有两种方法:
方法一
      1. 配置镜像(观测)端口
      [SwitchA]monitor-port e0/8
      2. 配置被镜像端口
      [SwitchA]port mirror Ethernet 0/1 to Ethernet 0/2
方法二
      1. 可以一次性定义镜像和被镜像端口
      [SwitchA]port mirror Ethernet 0/1 to Ethernet 0/2 observing-port Ethernet 0/8
【8016交换机端口镜像配置】
1. 假设8016交换机镜像端口为E1/0/15,被镜像端口为E1/0/0,设置端口1/0/15为端口镜像的观测端口。
      [SwitchA] port monitor ethernet 1/0/15
2. 设置端口1/0/0为被镜像端口,对其输入输出数据都进行镜像。
      [SwitchA] port mirroring ethernet 1/0/0 both ethernet 1/0/15
也可以通过两个不同的端口,对输入和输出的数据分别镜像
1. 设置E1/0/15和E2/0/0为镜像(观测)端口
[SwitchA] port monitor ethernet 1/0/15
2. 设置端口1/0/0为被镜像端口,分别使用E1/0/15和E2/0/0对输入和输出数据进行镜像。
[SwitchA] port mirroring gigabitethernet 1/0/0 ingress ethernet 1/0/15
[SwitchA] port mirroring gigabitethernet 1/0/0 egress ethernet 2/0/0

『基于流镜像的数据流程』
基于流镜像的交换机针对某些流进行镜像,每个连接都有两个方向的数据流,对于交换机来说这两个数据流是要分开镜像的。
【3500/3026E/3026F/3050】
〖基于三层流的镜像〗
1. 定义一条扩展访问控制列表
[SwitchA]acl num 100
2. 定义一条规则报文源地址为1.1.1.1/32去往所有目的地址
[SwitchA-acl-adv-101]rule 0 permit ip source 1.1.1.1 0 destination any
3. 定义一条规则报文源地址为所有源地址目的地址为1.1.1.1/32
[SwitchA-acl-adv-101]rule 1 permit ip source any destination 1.1.1.1 0
4. 将符合上述ACL规则的报文镜像到E0/8端口
[SwitchA]mirrored-to ip-group 100 interface e0/8

〖基于二层流的镜像〗
1. 定义一个ACL
[SwitchA]acl num 200
2. 定义一个规则从E0/1发送至其它所有端口的数据包
[SwitchA]rule 0 permit ingress interface Ethernet0/1 egress interface Ethernet0/2
3. 定义一个规则从其它所有端口到E0/1端口的数据包
[SwitchA]rule 1 permit ingress interface Ethernet0/2 egress interface Ethernet0/1
4. 将符合上述ACL的数据包镜像到E0/8
[SwitchA]mirrored-to link-group 200 interface e0/8

【5516/6506/6503/6506R】
目前该三款产品支持对入端口流量进行镜像
1. 定义镜像端口
[SwitchA]monitor-port Ethernet 3/0/2 
2. 定义被镜像端口
[SwitchA]mirroring-port Ethernet 3/0/1 inbound 

【补充说明】
1. 镜像一般都可以实现高速率端口镜像低速率端口,例如1000M端口可以镜像100M端口,反之则无法实现
2. 8016支持跨单板端口镜像
S8016端口镜像中观察端口业务功能支持情况
S8016各版本对端口镜像中观察端口跑业务功能的支持情况不同,升级时须注意。
S8016 VRP3.1 53XX版本支持观察端口跑业务;
S8016 VRP3.1 23XX版本不支持观察端口跑业务;
S8016 VRP5.3版本不支持观察端口跑业务。

三、 测试验证在观测端口上通过工具软件可以看到被镜像端口的相应的报文,可以进行流量观测或者故障定位。








2.17  D-link交换机
2.17.1  D-link 3226
将 端口 2 的所有数据复制一份到端口 1
DES-3226S:4#config mirror port 1 add source ports 2 both
看看配置
DES-3226S:4#show mirror
Command: show mirror
Current Settings
Mirror Status: Disabled
Target Port : 1
伏秒特性的绘制方法和含义Mirrored Port
RX: 2
TX: 2
注意 Mirror Status: Disabled 是 disable的 ,所以我们要打开
DES-3226S:4#enable mirror
Command: enable mirror
Success.
端口配完以后,有的朋友还要加这么一条命令
DES-3226S:4#config port mirroring source port b target port 1
这样端口就算完成




2.18  锐捷交换机
2.18.1  S1926F+交换机端口镜像设置图例
进入交换机主菜单

选择(P)进入端口设置界面

选择(C)进入端口配置界面


选择(I),进入被监控的端口的设置(实例中被监控端口为24口)

选择(M)进入镜像口的设置界面,选择镜像口(设置为除本身之外的其它端口,在此选择端口1对24口进行监控)


设置成功,保存配置(S)


注意事项:在S1926G+中,在同一时刻只可一个端口被设为被监控口,该被监控口允许有1个镜像端口,且监控端口与被监控端口需处在同一VLAN。

2.18.2  锐捷中高端交换机端口监控配置
例:fa0/2接口监控fa0/10接口的步骤如下:
Switch# configure terminal
!进入全局配置模式
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)# monitor session 1 source interface fastEthernet 0/10 both
!设置被监控口
2006-03-16 17:26:56  @5-CONFIG:Configured from outband
Switch(config)# monitor session 1 destination interface fastEthernet 0/2
!设置监控口
2006-03-16 17:27:19  @5-CONFIG:Configured from outband
Switch# show monitor session 1
!显示配置信息
Session: 1
Source Ports:
      Rx Only   : None
      Tx Only   : None
      Both      : Fa0/10
Destination Ports: Fa0/2
Switch# show running-config
!显示当前所有配置信息
System software version : 1.63 Build Jan  6 2006 Rel


Current configuration : 472 bytes

!
version 1.0
!
no enable services web-server
hostname Switch
vlan 1
!
enable secret level 1 5 &t>H.Y*TquC,tZ[VrvD+S(\Ws=G1X)sv
enable secret level 15 5 &ttj9=G1qu7R:>H.rvu_;C,ts8U0<D+S
!
interface vlan 1       
no shutdown
ip address 192.168.26.38 255.255.255.0
!
ip default-gateway 192.168.26.10
snmp-server community public ro
monitor session 1 destination interface fastEthernet 0/2
monitor session 1 source interface fastEthernet 0/10 both
end

例:创建一个SPAN会话并指定监控口和被监控口

1步骤
configure terminal
进入全局配置模式。
2步骤
no monitor session session_number
清除当前配置。
3步骤
monitor session session_number source interface interface-id [| ,-] {both | rx | tx}
指定源端口。对于session_number1,请指定。对于interface-id,请指定相应的接口号。
4步骤
monitor session session_number destination interface interface-id
指定源端口。对于session_number1,请指定。对于interface-id,请指定相应的接口号
5步骤
end
返回特权模式
6步骤
show monitor [session session_number]
确认您的配置

下面这个例子说明了如何创建一个会话:会话。首先,将当前会话的配置清除掉,然后设1MIRROR8置端口的帧到端口。
Show monitor session 特权命令用于确认配置。
Switch(config)# no monitor session 1
Switch(config)# monitor session 1 source interface gigabitEthernet1/1 both
Switch(config)# monitor session 1 destination interface gigabitEthernet 1/8
Switch(config)# end
Switch# show monitor session 1
Session 1
-----------
Souce Ports:
RX Only: None
TX Only: None
Both: Gi 1/1
Destination Ports: Gi 1/8
2.19  神州数码交换机
2.19.1  3526S/3926S端口镜像:
指定镜像源端口:
Switch(Config)#monitor  session  1 source interface e  1,2-4  0/0/2-4 tx
Switch(Config)#monitor session <session>  source interface e 端口列表 {tx,rx,both} rx为镜像源端口接收的流量;tx为镜像从源端口发出的流量;both为源端口入和出的流量。
指定镜像目的端口;
Switch(Config)# monitor session 1 destination interface eth 25 0/0/25为3926端口
Switch(Config)#monitor session <session> destination interface <interface-number>

2.19.2  其他配置型号端口镜像
命令: [no] mirror-port ethernet <portnum>
功能: 激活镜像端口
命令模式: 特权配置模式
参数: <portnum>为镜像端口的端口号
命令: [no] monitor ethernet <portnum> [ethernet <portnum>...] both | in | out
功能: 激活被镜像的端口的镜像功能
命令模式: 端口配置模式
参数: <portnum>为镜像端口端口号;both | in | out分别代表双向流量,输入流量,输出流量
举例一:
DCRS-7500(config)# mirror-port ethernet 4/1
DCRS-7500(config)# interface ethernet 4/3
DCRS-7500(config-if-4/3)# monitor ethernet 4/1 both
上述命令将端口4/3上的双向流量镜像到端口4/1,用户可以在端口4/1外接协议分析仪来查看端口4/3的流量信息。
举例二:
DCRS-7500(config)# interface ethernet 1/2
DCRS-7500(config-if-1/2)# monitor ethernet 1/1 in
神州数码(上海)网络有限公司 DCRS-7500 交换机用户手册
DCRS-7500(config-if-1/2)# interface ethernet 1/3
DCRS-7500(config-if-1/3)# monitor ethernet 1/1 in
DCRS-7500(config-if-1/3)# interface ethernet 1/4
DCRS-7500(config-if-1/4)# monitor ethernet 1/1 in
上述命令把端口1/2,1/3和1/4的输入流量镜像到端口1/1。


镜像链路聚合组中的单独端口

默认状态下,当镜像链路聚合组中的主端口时,链路聚合组中的所有端口的流量都被镜像到镜像端口。用户可以配置只镜像链路聚合组中的单独端口。
命令: [no] monitor ethe-port-monitored <portnum> | named-port-monitored <portname>
ethernet <portnum> in | out | both
功能: 镜像链路聚合组中的单独端口
命令模式: 链路聚合配置模式
参数: ethe-port-monitored <portnum> | named-port-monitored <portname>参数指定了链路聚合组中被镜像的端口,ethe-port-monitored <portnum>指定被镜像的端口号码,named-portmonitored <portname>指定被镜像的端口名称;ethernet | <portnum>指定镜像端口号码,这个端口外接协议分析仪;both | in | out分别代表双向流量,输入流量,输出流量
举例:
DCRS-7500(config)# mirror ethernet 2/1
DCRS-7500(config)# trunk switch ethernet 4/1 to 4/8
DCRS-7500(config-trunk-4/1-4/8)# monitor ethe-port-monitored 4/5 ethernet 2/1 in
上述命令设置端口2/1镜像链路聚合组中端口4/5的输入流量。
命令: [no] config-primary-ind
功能: 镜像链路聚合组中的主端口
命令模式: 链路聚合配置模式
举例:
DCRS-7500(config)# mirror ethernet 2/1
DCRS-7500(config)# trunk switch ethernet 4/1 to 4/8
DCRS-7500(config-trunk-4/1-4/8)# config-primary-ind
DCRS-7500(config-trunk-4/1-4/8)# monitor ethe-port-monitored 4/1 ethernet 2/1 out
上述命令设置端口2/1镜像链路聚合组中主端口4/1的输出流量。
显示端口镜像配置

命令: show monitor
神州数码(上海)网络有限公司 DCRS-7500 交换机用户手册
功能: 显示端口镜像配置
命令模式: 全局配置模式
举例:
DCRS-7500(config)# show monitor
Mirror Interface: ethernet 4/1
Monitored Interfaces:
Both Input Output
---------------------------------------------------
ethernet 4/3

本文发布于:2024-09-23 00:35:13,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/3/136705.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:端口   镜像   监控   交换机   配置   流量
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议