您的位置:首页 > 其它

什么是端口镜像以及端口镜像的分类?

2010-11-16 20:18 176 查看
先解释一下端口镜像:端口镜像简单的说,就是把交换机一个(数个)端口(源端口)的流量完全拷贝一份,从另外一个端口(目的端口)发出去,以便网络管理人员从目的端口通过分析源端口的流量来找出网络存在问题的原因。

cisco的端口镜像叫做SWITCHED PORT ANALYZER,简称SPAN(仅在IOS系统中,下同),因此,端口镜像仅适用于以太网交换端口。Cisco的SPAN

分成三种,SPAN、RSPAN和VSPAN,简单的说,SPAN是指源和目的端口都在同一台机器上、RSPAN指目的和源不在同一交换机上,VSPAN可以镜像整个或数个VLAN到一个目的端口。

配置方法:

1. SPAN

(1) 创建SPAN源端口

monitor session session_number source interface interface-id [, | -] [both | rx | tx]

**session_number,SPAN会话号,我记得3550支持的最多本地SPAN是2个,即1或者2。

**interface-id [, | -]源端口接口号,即被镜像的端口,交换机会把这个端口的流量拷贝一份,可以输入多个端口,多个用“,”隔开,

连续的用“-”连接。

**[both | rx | tx],可选项,是指拷贝源端口双向的(both)、仅进入(rx)还是仅发出(tx)的流量,默认是both。

(2)创建SPAN目的端口

monitor session session_number destination interface interface-id [encapsulation {dot1q [ingress vlan vlan id] | ISL

[ingress]} | ingress vlan vlan id]

**一样的我就不说了。

**session_number要和上面的一致。

**interface-id目的端口,在源端口被拷贝的流量会从这个端口发出去,端口号不能被包含在源端口的范围内。

**[encapsulation {dot1q | isl}],可选,指被从目的端口发出去时是否使用802.1q和isl封装,当使用802.1q时,对于本地VLAN不进行封

装,其他VLAN封装,ISL则全部封装。

2.VSPAN

(1)创建VSPAN源VLAN

monitor session session_number source vlan vlan-id [, | -] rx

**一样的也不说了,基本和SPAN相同,只是接口号变成了VLAN号,而且只能镜像接收的流量。

(2)创建VSPAN目的端口

monitor session session_number destination interface interface-id [encapsulation {dot1q | isl}]

**和SPAN的一样。

3.RSPAN

RSPAN的配置较为复杂,其流程可以这样来看,交换机把要镜像的端口流量复制一份,然后发到本机的一个反射端口上(reflector-port )

,在由反射端口将其通过网络转发到目的交换机中的VLAN上(一般情况下,这个VLAN是专为镜像而设的,不要作为客户端接入所用),再在目

的交换机中配置VSPAN,将该VLAN的流量镜像到目的端口,要注意的是,一旦这种RSPAN被使用,该镜像专用VLAN的信息会被转发到所有的VLAN

主干上,造成网络带宽的浪费,因此要配置VLAN修剪(pruning),另外RSPAN也可以镜像VLAN。

(1)在源交换机上创建RSPAN源端口

**同SPAN或VSPAN

(2)在源交换机上创建VSPAN反射端口和目的VLAN

monitor session session_number destination remote vlan vlan-id reflector-port interface

**vlan-id 目的交换机上转为镜像而设的VLAN

**reflector-port interface源交换机上的镜像端口

(3)在目的交换机上创建VSPAN源VLAN

monitor session session_number source remote vlan vlan-id

**vlan-id就是上面的镜像专用VLAN

(4)在目的交换机上创建VSPAN目的端口

monitor session session_number destination interface interface-id [encapsulation {dot1q | isl}]

**同SPAN

4.其他

(1)端口镜像的过滤,端口镜像是可以做Filter的。

monitor session session_number filter vlan vlan-id [, | -]

**指定源端口进入的流量中,属于哪些VLAN的可以从目的端口发出去。

(2)删除镜像

no monitor session {session_number | all | local | remote}

**session_number指定会话号,all是所有镜像,local是本地镜像,remote是远程镜像。

(3)镜像的目的端口不能正常收发数据,因此不能再作为普通端口使用,可以连接一些网络分析和安全设备,例如装有sniifer的计算机或者Cisco IDS设备。

SPAN特性不会影响源端口的正常工作,也不会影响正常的交换机操作。在交换网络中可以配置多个SPAN会话,只有当目的端口可操作,同时源端口或源VLAN中的任意一个端口活动时才可激活SPAN会话。

下面是一些配置SPAN会话的例子:

1 建立一个SPAN会话,监视某端口的数据流:

Switch(config)# monitor session 1 source interface fastEthernet0/1

Switch(config)# monitor session 1 destination interface fastEthernet0/10 encapsulation dot1q

本配置将监视所有出入端口fastethernet0/1的数据流,凡是经过该端口的数据都会copy一份并被送到端口fastethernet0/10上去。

2利用端口fastethernet0/5监视本交换机上vlan5的入流量:

Switch(config)# monitor session 1 destination interface Fa 0/5 ingress vlan 5

3 另外,在建立一个SPAN会话前,需要保证之前存在于该会话中的定义被清除,然后再给会话1新的定义。

Switch(config)# no monitor session 1

4 下面的配置首先将会话1的配置清除,然后定义将某端口的数据映射到监测端口上:

Switch(config)# no monitor session 1

Switch(config)# monitor session 1 source interface fastEthernet0/10 tx

Switch(config)# monitor session 1 destination interface fastEthernet0/1

Switch(config)# end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: