switch#conf t
switch(config)# no monitor session {session-number | all | local | remote}
all 清除所有 local 清除本地  remote 清除远程
switch(config)#monitor session  session-number source interface interface-id [ , | -] [both | rx | tx ]
port-channel port-channel-number  both 双向 rx 接收 tx 发送
switch(config)# monitor session session-number destination interface interface-id [encapsulation {dot1q | isl }]
switch#show monitor session session-number
 
switch(config)#no monitor session 1
switch(config)#monitor session 1 source interface fastethernet 0/1
switch(config)#monitor session 1 destination interface fastether 0/10 encapsulation dot1q
switch(config)#end
 
switch(config)#no monitor session 1 source interface fastethernet 0/1
swtich(config)#no monitor session 1 desination interface fastethernet 0/10
 
一个端口不能兼做目的的端口和源端口
一个etherchannel 端口只能做为SPAN的源端口
对SPAN端口,可以监控一个端口或一段范围内端口的发送和接收流量
配置为SPAN目的端口的一个交换机端口不再是一个标准的交换机端口,只有被监控的流量通过SPAN目的端口
一个SPAN目的端口不参与任何VLAN 的生成树,尽管源端口上的生成树BPDU或VLAN流量会被复制的到SPAN目的端口上
 
SPAN 可以基于VLAN使用。一个源VLAN 是一个为了网络流量分析的被监控VLAN。VSPAN 使用一个或多个VLAN 做为SPAN的源。源VLAN 中的所有端口成为源端口。对于VSPAN,只能监控进入的流量(rx 流量)。
 
switch(config)# no monitor session 1
switch(config)#monitor session 1 source vlan 1 - 3 rx
switch(config)#monitor session 1 destination interface gigabitethernet 0/7
switch(config)#monitor sesssion 1 source vlan 10 rx
switch(config)#end
switch#show monitor session 1
switch(config)#no monitor session 1 source vlan 10 rx
switch(config)#no monitor session 1 destination interface gigabitethernet 0/7