交換機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 

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