一、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 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 OnlyBoth : Fa0/10 //注意此处还是Both

Destination Ports : Fa0/20

Encapsulation : Native

Ingress: Disabled

Switch(config)# monitor session 1 destination interface fa0/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、Specifying VLANs to Filter

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、Configuring RSPAN——配置远程RSPAN

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

3.1、首先要配置专用的RSPAN VLAN

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中的流量

3.2、配置RSPAN Source Session

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

------- --------- -----------------

3.3、配置RSPAN Destination 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 destina remote vlan 800
reflector-port fa0/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

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

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

你得在交换机上做一个端口镜像,让其它端口的数据都复制一份到你所接入的这个端口上来,用sniffer软件就可以了,但你所在的这个端口只能做管理接口使用,别的就什么都不能做了。命令:

SW-3L(config)#monitor session 1 source int f0/1 both
所要抓的包所在的端口

SW-3L(config)#monitor session 1 destination int f0/24
你的机器连接的端口

[转载]抓包,端口镜像,monitor session命令(转)的更多相关文章

  1. Android抓包方法(二)之Tcpdump命令+Wireshark

    Android抓包方法(二) 之Tcpdump命令+Wireshark 前言 做前端测试,基本要求会抓包,会分析请求数据包,查看接口是否调用正确,数据返回是否正确,问题产生是定位根本原因等.学会抓包分 ...

  2. Microsoft Message Analyzer (微软消息分析器,“网络抓包工具 - Network Monitor”的替代品)官方正式版现已发布

    来自官方日志的喜悦 被誉为全新开始的消息分析器时代,由MMA为您开启,博客原文写的很激动,大家可以点击这里浏览:http://blogs.technet.com/b/messageanalyzer/a ...

  3. Microsoft Message Analyzer (微软消息分析器,“网络抓包工具 - Network Monitor”的替代品)官方正式版现已发布

    Microsoft Message Analyzer (微软消息分析器,“网络抓包工具 - Network Monitor”的替代品)官方正式版现已发布 来自官方日志的喜悦 被誉为全新开始的消息分析器 ...

  4. [转载]抓包工具Charles乱码解决办法

    FROM: http://blog.csdn.net/huanghanqian/article/details/52973651 安装 SSL 证书 Mac 端 首先去 http://www.char ...

  5. 聊聊tcpdump与Wireshark抓包分析

    1 起因# 前段时间,一直在调线上的一个问题:线上应用接受POST请求,请求body中的参数获取不全,存在丢失的状况.这个问题是偶发性的,大概发生的几率为5%-10%左右,这个概率已经相当高了.在排查 ...

  6. NetScaler循环抓包设置

    NetScaler循环抓包设置 来源 https://raynorli.com/2018/07/01/netscaler-nstrace-cycling-capture/ 参考文档 How to Re ...

  7. linux下共享热点抓包

    Linux有一个抓包工具叫tcpdump,这个命令还是挺强大的.简单列举一下它的参数 # tcpdump -h tcpdump version 4.9.2 libpcap version 1.8.1 ...

  8. linux下使用tcpdump抓包分析tcp的三次握手

    首先贴上tcp 三次握手的原理图服务器开启ftp服务并执行tcpdump抓包服务器:192.168.3.14 ftp服务客户端:192.168.3.100 服务器执行以下命令,客户端访问服务器ftp: ...

  9. 跨平台网络抓包工具-Microsoft Message Analyzer

    Microsoft Message Analyzer (MMA 2013)是微软最受欢迎的Netmon的最新版本. 在Netmon网络跟踪和排除故障功能的基础上提供了更强大的跨平台网络分析追踪能力.园 ...

随机推荐

  1. You must use the Role Management Tool to install or configure Microsoft .NET Framework 3.5 SP1

    今天在Windows Server 2008 下安装SQL SERVER 2008时,碰到如下错误: You must use the Role Management Tool to install ...

  2. ajax请求技术

    1.写在前面: 阅读要求: 具有一定的HTML.CSS.JavaScript.Json基础 2.什么是ajax Ajax:即”Asynchronous Javascript And XML”(异步Ja ...

  3. YII2 项目安装步骤及异常记录

    项目环境: 操作系统:windows 7 版本管理:git 该项目我是在mac上面创建的,mac上面的环境也是一波三折啊!但我同事的环境是在windows上面,因为是前端同学,所以只好我再次操刀了.. ...

  4. W3School-CSS 尺寸 (Dimension) 实例

    CSS 尺寸 (Dimension) 实例 CSS 实例 CSS 背景实例 CSS 文本实例 CSS 字体(font)实例 CSS 边框(border)实例 CSS 外边距 (margin) 实例 C ...

  5. Xamarin Android 所见即所得问题

    运行Xamarin 时出现以下问题. The layout could not be loaded : The operation failed due to an internal error : ...

  6. AngularJS笔记---作用域和控制器

    什么是作用域. 什么是控制器, 作用域包含了渲染视图时所需的功能和数据,它是所有视图的唯一源头.可以将作用域理解成试图模型(ViewModel). 作用域之间可以是包含关系也可以是独立关系.可以通过设 ...

  7. 【转载】Serif和Sans-serif字体的区别

    在西方国家罗马字母阵营中,字体分为两大种类:Sans Serif和Serif,打字机体虽然也属于Sans Serif,但由于是等宽字体,所以另外独立出Monospace这一种类,例如在Web中,表示代 ...

  8. MBTI-性格测试

  9. [普通平衡树treap]【学习笔记】

    3224: Tyvj 1728 普通平衡树 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 9046  Solved: 3840[Submit][Sta ...

  10. sicily vector有序插入

    实现了简单的vector有序插入,这个题目值得注意的点是1.当vector为空时,需要判断再排除 2.迭代器的使用是此段代码的特点 int insertVector(vector<int> ...