交换机SPAN技术简介+Cisco配置示例

  一、SPAN简介 SPAN技术主要是用来监控交换机上的数据流,大体分为两种类型,本地SPAN和远程SPAN. ----Local Switched Port Analyzer (SPAN) and Remote SPAN (RSPAN),实现方法上稍有不同。 利用SPAN技术我们可以把交换机上某些想要被监控端口(以下简称受控端口)的数 
  一、SPAN简介   SPAN技术主要是用来监控交换机上的数据流,大体分为两种类型,本地SPAN和远程SPAN. ----Local Switched Port Analyzer (SPAN) and Remote SPAN (RSPAN),实现方法上稍有不同。   利用SPAN技术我们可以把交换机上某些想要被监控端口(以下简称受控端口)的数据流COPY或MIRROR一份,发送给连接在监控端口上的流量分析仪,比如CISCO的IDS或是装了SNIFFER工具的PC. 受控端口和监控端口可以在同一台交换机上(本地SPAN),也可以在不同的交换机上(远程SPAN)。   二、名词解释   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. )   三、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,但有些限制。
 四、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 monSession 1---------Type : Local SessionSource Ports :Both : Fa0/10 //注意此处是BothDestination Ports : Fa0/20Encapsulation : NativeIngress: DisabledSwitch(config)# monitor session 1 source interface fastethernet0/11 - 13//添加SPAN的受控端口Switch#sh monSession 1---------Type : Local SessionSource Ports :RX Only : Fa0/11-13 //注意此处是RX OnlyBoth : Fa0/10 //注意此处还是BothDestination Ports : Fa0/20Encapsulation : NativeIngress: DisabledSwitch(config)# monitor session 1 destination interface fa0/20 ingress vlan 5//设定SPAN的监控端口并启用二层转发Switch#sh monSession 1---------Type : Local SessionSource Ports :RX Only : Fa0/11-13Both : Fa0/10Destination Ports : Fa0/20Encapsulation : NativeIngress: Enabled, default VLAN = 5 //允许正常的流量进入Ingress encapsulation: Native

  3、Specifying VLANs to Filter

Switch(config)# no monitor session 2Switch(config)# monitor session 2 source vlan 101 - 102 rxSwitch(config)# monitor session 2 destination interface fastethernet0/30Switch#sh mon ses 2Session 2---------Type : Local SessionSource VLANs :RX Only : 101-102 //注意此处是RX OnlyDestination Ports : Fa0/30Encapsulation : NativeIngress: DisabledSwitch(config)# monitor session 2 source vlan 201 - 202 rxSwitch#sh mo se 2Session 2---------Type : Local SessionSource VLANs :RX Only : 101-102,201-202 //注意此处多了201-202Destination Ports : Fa0/30Encapsulation : NativeIngress: Disabled

4、Configuring RSPAN——配置远程RSPAN   RSPAN的Session分成RSPAN Source Session和RSPAN Destination Session两部分,所以相应的配置也要分别在Session的源和目的交换机上做。   4.1、首先要配置专用的RSPAN VLAN Switch(config)# no monitor session 2Switch(config)# monitor session 2 source interface fastethernet0/48 rxSwitch(config)# monitor session 2 filter vlan 100 - 102 //指定受控的VLAN范围Switch(config)# monitor session 2 destination interface fastethernet0/30Switch#sh mon ses 2Session 2---------Type : Local SessionSource Ports :Both : Fa0/48Destination Ports : Fa0/30Encapsulation : NativeIngress: DisabledFilter VLANs : 100-102 //只监控VLAN100-102中的流量 
  4.2、配置RSPAN Source Session Switch(config)# vlan 800Switch(config-vlan)# remote-spanSwitch(config-vlan)# endsw1#sh vl id 800VLAN Name Status Ports---- -------------------------------- 800 VLAN0800 active Fa0/47, Fa0/48VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2---- ----- ---------- ----- ------ 800 enet 100800 1500 - - - - - 0 0Remote SPAN VLAN----------------Enabled //注意看此处的提示Primary Secondary Type Ports------- --------- -----------------
  4.3、配置RSPAN Destination Session Switch(config)# no monitor session 1Switch(config)# monitor session 1 source interface fastethernet0/10 - 13Switch(config)# monitor session 1 source interface fastethernet0/15 rxSwitch(config)# monitor session 1 destina remote vlan 800 reflector-port fa0/20sw1#sh mo se 1Session 1---------Type : Remote Source SessionSource Ports :RX Only : Fa0/11-13,Fa0/15Both : Fa0/10Reflector Port : Fa0/20Dest RSPAN VLAN : 800 
  (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 {mod/ports... | vlans...} {rspan_vlan} reflector mod/port [rx | tx | both]
[filter vlans...] [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 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章