SPAN端口主要是监控交换机上的数据流,分为本地span和远程span。
利用SPAN技术我们可以把交换机上某些想要被监控端口的数据流COPY或MIRROR一份,发送给连接在监控端口上的流量分析仪,比如CISCO的IDS或是装了SNIFFER工具的PC. 受控端口和监控端口可以在同一台交换机上(本地SPAN),也可以在不同的交换机上(远程SPAN)。
我们边看命令变说明
sw(config)#monitor session ?
<1-2> SPAN session number 指定session号 1
sw(config)#monitor session 1 ?
destination SPAN destination interface or VLAN 2
filter SPAN filter VLAN
source SPAN source interface or VLAN 4
sw(config)#monitor session 1 so
sw(config)#monitor session 1 source ?
interface SPAN source interface 5
vlan SPAN source VLAN 6
sw(config)#monitor session 1 source in
sw(config)#monitor session 1 source interface ?
FastEthernet FastEthernet IEEE 802.3
Port-channel Ethernet Channel of interfaces
1. SPAN Session——SPAN会话
SPAN会话是指一组受控端口与一个监控端口之间的数据流。可以同时对多个端口的进入流量或是一个端口的外出流量进行监控,也可以对VLAN内所有端口的进入流量进行监控,但不能同时对多个端口的外出流量及VLAN的外出流量进行监控,可以对处于关闭状态的端口设置SPAN,但此时的SPAN会话是非活动,但只要相关的接口被打开,SPAN就会变为活动的。
监控端口最好是>=受控端口的带宽,否则可能会出现丢包的情况。
2. 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)。
3. 4.5 Source Port——SPAN会话的源端口(也就是monitored port-即受控端口)
受控端口可以是实际的物理端口、VLAN、以太通道端口组EtherChannel,物理端口可以在不同的VLAN中,受控端口如果是VLAN则包括此VLAN中的所以物理端口,受控端口如果是以太通道则包括组成此以太通道组的所有物理端口,如果受控端口是一个TRUNK干道端口,则此TRUNK端口上承载的所有VLAN流量都会受到监控,也可以使用filter vlan 参数进行调整,只对filter vlan 中指定的VLAN数据流量做监控。
sw(config)#monitor session 1 source interface ?
FastEthernet FastEthernet IEEE 802.3
Port-channel Ethernet Channel of interfaces
sw(config)#monitor session 1 source interface f1/5 ? 7
, 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
7. 被监控的流量类型分为三种,Receive (Rx) SPAN 受控端口的接收流量,Transmit (Tx) SPAN 受控端口的发送流量,Both 一个受控端口的接收和发送流量。
假如sniffer监控本交换机的端口流量
Switch(config)# monitor session 2 source vlan 101 - 102 rx
Switch(config)# monitor session 2 destination interface fastethernet0/30
sw(config)#monitor session 1 filter vlan 2 -5
remote span
1.vtp
2.vlan remote-span 两边都要做
3.
Reflector Port——反射端口
反射端口只在RSPAN中使用,与RSPAN中的受控端口在同一台交换机上,是用来将本地的受控端口流量转发到RSPAN中在另一台交换机上的远程监控端口的方法,反射端口也只能是一个实际的物理端口,它不属于任何VLAN(It is invisible to all VLANs.)。一般高版本的交换机像65,就不需要设置reflector port 直接trunk走人了!
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的SPAN只能监控VLAN中所有活动端口接收的流量(only received (Rx) traffic),如果监控端口属于此VLAN,则此端口不在监控范围内,VSPAN只监控进入交换机的流量,不对VLAN接口上的路由数据做监控。
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,但有些限制。
第一个被设为受控端口的接口进出流量都会受到监控,以后再追加的受控端口只会对接收的流量进行监控,监控端口的默认封装类型为Native,也就是没有打VLAN的标记。
SPAN interacts with these features:
"Spanning Tree Protocol (STP)—A destination port does not participate in STP while its SPAN or RSPAN session is active. The destination port can participate in STP after the SPAN or RSPAN session is disabled. On a source port, SPAN does not affect the STP status. STP can be active on trunk ports carrying an RSPAN VLAN.
"Cisco Discovery Protocol (CDP)—A SPAN destination port does not participate in CDP while the SPAN session is active. After the SPAN session is disabled, the port again participates in CDP.
"VLAN Trunking Protocol (VTP)—You can use VTP to prune an RSPAN VLAN between switches.
"VLAN and trunking—You can modify VLAN membership or trunk settings for source or destination ports at any time. However, changes in VLAN membership or trunk settings for a destination port do not take effect until you remove the SPAN destination configuration. Changes in VLAN membership or trunk settings for a source port immediately take effect, and the respective SPAN sessions automatically adjust accordingly.
"EtherChannel—You can configure an EtherChannel group as a source port but not as a SPAN destination port. When a group is configured as a SPAN source, the entire group is monitored.
If a physical port is added to a monitored EtherChannel group, the new port is added to the SPAN source port list. If a port is removed from a monitored EtherChannel group, it is automatically removed from the source port list. If the port is the only port in the EtherChannel group, because there are no longer any ports in the group, there is no data to monitor.
A physical port that belongs to an EtherChannel group can be configured as a SPAN source port and still be a part of the EtherChannel. In this case, data from the physical port is monitored as it participates in the EtherChannel. However, if a physical port that belongs to an EtherChannel group is configured as a SPAN destination, it is removed from the group. After the port is removed from the SPAN session, it rejoins the EtherChannel group. Ports removed from an EtherChannel group remain members of the group, but they are in the inactive or standalone state.
If a physical port that belongs to an EtherChannel group is a destination port and the EtherChannel group is a source, the port is removed from the EtherChannel group and from the list of monitored ports.
"Multicast traffic can be monitored. For egress and ingress port monitoring, only a single unedited packet is sent to the SPAN destination port. It does not reflect the number of times the multicast packet is sent.
"A secure port cannot be a SPAN destination port.
For SPAN sessions, do not enable port security on ports with monitored egress when ingress forwarding is enabled on the destination port. For RSPAN source sessions, do not enable port security on any ports with monitored egress.
"An 802.1x port can be a SPAN source port. You can enable 802.1x on a port that is a SPAN destination port; however, 802.1x is disabled until the port is removed as a SPAN destination.
For SPAN sessions, do not enable 802.1x on ports with monitored egress when ingress forwarding is enabled on the destination port. For RSPAN source sessions, do not enable 802.1x on any ports that are egress monitored.