交换机与路由器技术-36-端口镜像

目录

一、端口镜像

1.1 概述

1.2 目的

1.3 功能

1.4 端口镜像应用场景

1.4.1 本地端口镜像(SPAN)

1.4.2 远程端口镜像(RSPAN)

1.5 配置本地端口

1.6 配置远程端口镜像(RSPAN)


一、端口镜像

1.1 概述

端口镜像(port Mirriring)功能是通过在交换机或路由器上、将一个或多个源端口的数据流量转发到某个指定端口实现对网络的监听,指定端口称为镜像端口,或者目的端口。在不严重影响源端口正常吞吐量的情况下,可以通过镜像端口对网络的流量进行监控分析。在企业中用镜像功能,可以更好的对企业内部的网络数据进行监控管理。在网络上出现故障时,可以快速定位故障。

1.2 目的

主要是为了方便一个或多个网络接口的流量进行分析。如IDS入侵检测产品、网络分析仪等。可以通过配置交换机或路由器,将一个或多个端口(VLAN)的数据转发到某个端口。即镜像端口来实现对网络的监听。

1.3 功能

将被监控流量镜像到监控端口,以便对被监控流量进行故障定位、流量分析、流量备份等。监控端口一般直接与监控主机等相连

1.4 端口镜像应用场景

1.4.1 本地端口镜像(SPAN)

在同一台交换机上将一些接口的流量镜像到另一个接口上(镜像端口)

1.4.2 远程端口镜像(RSPAN)

将交换机或路由器的一些接口的流量镜像到另一台交换机的某个接口上

实验

1.5 配置本地端口

要求:将f0/0源接口的流量镜像到f0/2

步骤一:配置源端口(被镜像的端口)

sw1(config)#monitor ?

  event-trace  Tracing of system events

  session      Configure a SPAN session

sw1(config)#monitor session ?

  <1-2>  SPAN session number

sw1(config)#monitor session 1 ?

  destination  SPAN destination interface or VLAN

  filter       SPAN filter VLAN

  source       SPAN source interface or VLAN

sw1(config)#monitor session 1 source ?

  interface  SPAN source interface

  vlan       SPAN source VLAN

sw1(config)#monitor session 1 source interface ?

  FastEthernet  FastEthernet IEEE 802.3

  Port-channel  Ethernet Channel of interfaces

sw1(config)#monitor session 1 source interface fastEthernet 0/0 ?

  ,     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

  <cr>

/* both 监控双向流量 rx监控进入的流量 tx监控出去的流量 */

sw1(config)#monitor session 1 source interface fastEthernet 0/0 both

sw1(config)#

步骤二:配置镜像端口

sw1(config)#monitor session 1 ?

  destination  SPAN destination interface or VLAN

  filter       SPAN filter VLAN

  source       SPAN source interface or VLAN

sw1(config)#monitor session 1 destination ?

  interface  SPAN destination interface

/* f0/2 为镜像端口 */

sw1(config)#monitor session 1 destination interface f0/2

实验效果

当PC1访问PC2  PC3可以监听到数据流量

wireshark是抓取的sw1和PC3之间的流量

1.6 配置远程端口镜像(RSPAN)

将SW1的f0/0和f0/2的端口镜像到sw2的f0/1

工作流程:

交换机把被镜像端口的流量复制一份,然后发到本地的反射端口(一个还没有被使用的空闲端口),再由反射端口通过网络转发到目的交换机的vlan上。(一般情况下,这个vlan是专门为镜像而设的,不要作为客户端接入使用),再在目的交换机中配置SPAN将该VLAN的流量镜像到目的端口。

VSPAN:基本和SPAN相同,只是接口号变成了vlan号,而且只能镜像接收的流量。

配置步骤:

源端口交换机配置

/* vlan号必须独立于已经使用的vlan,不能和业务vlan相同 */

Switch1(config)#vlan 101

/* 模式改成RSPAN,特殊vlan用来做端口镜像 */

Switch1(config-vlan)#remote-span 

/* 配置要抓取原端口的流量 */

Switch1(config)#monitor session 1 source interface f0/1

Switch1(config)#monitor session 1 source interface f0/2

/* 目的端口配置为SPAN的vlan号*/

Switch1(config)#monitor session 1 destination remote vlan 101 reflector-port f0/23

目的端口交换机配置

/* vlan要和被抓取流量端口的交换机vlan要一致 */

Switch2(config)#vlan 101

/* 模式改成RSPAN,特殊vlan用来做端口镜像 */

Switch2(config-vlan)#remote-span

/* 配置要抓取源端口的流量,这里的session 号不需要和Switch1的一致 */

Switch2(config)#monitor session 1 destination interface f 0/2

/*目的端口配置为SPAN的vlan号 */

Switch2(config)#monitor session 1 source remote vlan 101

/* 查看端口镜像配置 */

Switch#show monitor

猜你喜欢

转载自blog.csdn.net/weixin_46232917/article/details/127054361