产品
产品中心
< 返回主菜单
产品

交换机

交换机所有产品
< 返回产品
交换机
查看交换机首页 >

无线

无线所有产品
< 返回产品
无线
查看无线首页 >

云桌面

云桌面产品方案中心
< 返回产品
云桌面
查看云桌面首页 >

安全

安全所有产品
< 返回产品
安全
查看安全首页 >
产品中心首页 >
行业
行业中心
< 返回主菜单
行业
行业中心首页 >

镜像是什么,如何配置?

发布时间:2023-03-24
点击量:560

镜像功能介绍

镜像功能概述

随着网络的发展,对网络的高可用性的要求日益提高。当网络出现异常时,需要对网络节点或者设备的端口进行了数据流量分析以便网络能够快速恢复正常,但同时又要求不影响设备数据流量的正常转发。

镜像是将指定端口的报文复制到另一个连接有网络监测设备的端口的功能,实现了对可疑的网络节点或者设备端口进行数据流量分析,同时又不影响被监控设备的数据转发。镜像功能主要应用在网络监控和故障排查两种场景中,实现了监控网络信息安全和解决网络故障的目的。

基本概念

1.    源端口

源端口也称为被监控口,源端口上的数据流会被复制一份到目的端口,用于网络分析或故障排除。

2.    目的端口

目的端口也称为为监控口,与监控设备相连接的端口,将接收到的源端口报文转发到监控设备。

3.    会话

会话是一个逻辑上的概念,一个完整的会话由源端口和目的端口组成。

4.    SPAN

SPANSwitch Port Analyzer,交换式端口分析器)也称为本地端口镜像或者本地镜像。指同一个镜像会话的源端口与目的端口在同一台设备上的镜像。

5.    RSPAN

RSPANRemote Switch Port Analyzer远程端口镜像)是SPAN的扩展,源端口和目标端口处于不同的设备。

6.    ERSPAN

ERSPANEncapsulated Remote Switch Port Analyzer,封装远程端口镜像)是RSPAN的扩展,实现了跨越交换或路由网络的多台设备的远程监控方法。

7.    远程镜像VLAN

远程镜像VLAN是一种特殊的VLAN,该VLAN只传输镜像报文,不对正常的业务数据进行传输。

8.    输出端口

源设备上将镜像报文发送到中间设备或者目的设备的端口称为输出端口。

9.    源设备

源设备是远程镜像角色之一,指源端口所在的设备,负责将源端口的报文复制一份到源设备的输出端口,传输给中间设备目的设备

10.  目的设备

目的设备远程镜像角色之一,指远程镜像目的端口所在的设备,负责将中间设备或者源设备接收到的镜像报文转发给监控设备。

11.  中间设备

中间设备是远程镜像角色之一,指处于源设备和目的设备之间的设备,负责将镜像报文传输给下一个中间设备或目的设备。如果源设备与目的设备直接相连,则不存在中间设备。

12.  镜像数据流

镜像数据流指被镜像的数据报文。镜像会话的数据流包含以下三种方向的数据流:

l  输入数据流

所有源端口上接收到的报文都将被复制一份到目的端口。在一个镜像会话中,可以监控一个或多个源端口的输入报文。

l  输出数据流

所有从源端口发送的报文都将复制一份到目的端口。在一个镜像会话中,可以监控一个或多个源端口的输出报文。

l  双向数据流

同时包含输入数据流和输出数据流。在一个镜像会话中,可监控一个或多个源端口的输入和输出方向的数据流。

典型配置举例

1  SPAN配置举例

1.    组网需求

1-6所示,通过适当的配置,网络分析仪能够监控DeviceA转发给DeviceB的所有数据流,监控来自DeviceB的特定数据流(如来自PC1PC2的数据流)。

2.    组网图

图1-6     SPAN组网图

 

3.    配置要点

l  配置DeviceAGigabitEthernet 0/1GigabitEthernet 0/2属于VLAN 1。创建SVI 1,并配置SVI 1地址为10.10.10.10/24

l  配置DeviceBGigabitEthernet 0/1属于VLAN 1。创建SVI 1,并配置SVI 1地址为10.10.10.20/24

l  配置PC1PC2的地址分别为10.10.10.1/2410.10.10.2/24

l  配置DeviceA的本地镜像,指定端口GigabitEthernet 0/1GigabitEthernet 0/2分别为镜像的源端口和目的端口。监控DeviceA转发给DeviceB的所有数据流,监控来自DeviceB的特定数据流。

4.    配置步骤

配置DeviceAGigabitEthernet 0/1GigabitEthernet 0/2属于VLAN 1

DeviceA> enable

DeviceA# configure terminal

DeviceA(config)# vlan 1

DeviceA(config-vlan)# exit

DeviceA上创建SVI 1,并配置SVI 1地址为10.10.10.10/24

DeviceA(config)# interface vlan 1

DeviceA(config-if-VLAN 1)# ip address 10.10.10.10 255.255.255.0

DeviceA(config-if-VLAN 1)# exit

配置DeviceBGigabitEthernet 0/1属于VLAN 1

DeviceB# configure

DeviceB(config)# vlan 1

DeviceB(config-vlan)# exit

DeviceB上创建SVI 1,并配置SVI 1地址为10.10.10.20/24

DeviceB (config)# interface vlan 1

DeviceB(config-if-VLAN 1)# ip address 10.10.10.20 255.255.255.0

DeviceB(config-if-VLAN 1)# exit

DeviceA上配置ACL,匹配源地址为10.10.10.20的报文。

DeviceA(config)# access-list 100 permit ip host 10.10.10.20 any

DeviceA上配置端口GigabitEthernet 0/1为镜像的源端口,监控DeviceA转发给DeviceB的所有数据流,监控来自DeviceB的特定数据流。

DeviceA(config)# monitor session 1 source interface gigabitethernet 0/1 tx

DeviceA(config)# monitor session 1 source interface gigabitethernet 0/1 rx acl 100

DeviceA上配置GigabitEthernet 0/2为镜像的目的端口。

DeviceA(config)# monitor session 1 destination interface gigabitethernet 0/2

5.    验证配置结果

通过show monitor命令查看镜像是否正确配置。

DeviceA# show monitor

sess-num: 1

span-type: LOCAL_SPAN

src-intf:

 GigabitEthernet 0/1     frame-type TX Only

src-intf:

 GigabitEthernet 0/1     frame-type RX Only

rx acl id 100

dest-intf:

 GigabitEthernet 0/2

6.    配置文件

l  DeviceA的配置文件

hostname DeviceA

!

ip access-list extended 100

 10 permit ip host 10.10.10.20 any

!

interface VLAN 1

 ip address 10.10.10.10 255.255.255.0

!

monitor session 1 destination interface GigabitEthernet 0/2

monitor session 1 source interface GigabitEthernet 0/1 tx

monitor session 1 source interface GigabitEthernet 0/1 rx acl 100

!

end

l  DeviceB的配置文件

hostname DeviceB

!

interface VLAN 1

 ip address 10.10.10.20 255.255.255.0

!

end

2  基于RSPAN实现的一对多镜像功能配置举例

*    警告

当部署一对多端口镜像时,必须使用switchport trunk allowed vlan remove vlan-list命令裁剪掉各镜像设备上trunk类型的接口中广播的VLAN,否则trunk接口可能会被广播的流量占满导致业务中断。

 

1.    组网需求

1-7所示,网络分析仪可以通过远程镜像功能,实现在目的设备DeviceBDeviceC上监控源设备DeviceA上的双向数据流。且设备之间均能正常交换数据。

2.    组网图

图1-7     基于RSPAN实现的一对多镜像功能网图

 

3.    配置要点

l  配置DeviceA为源设备,配置远程镜像VLAN,配置端口GigabitEthernet 0/1为源端口,与目的设备相连的端口GigabitEthernet 0/3GigabitEthernet 0/4为输出端口,配置GigabitEthernet 0/2接口为MAC回环口,用于实现一对多镜像的“反射”功能。配置输出端口可交换功能。

l  DeviceBDeviceC配置为目的设备,配置远程镜像VLAN,与源设备相连的端口GigabitEthernet 0/1作为源端口,配置Trunk端口,与网络分析仪相连的端口GigabitEthernet 0/2配置为镜像目的端口,并配置镜像目的端口可交换功能。

4.    配置步骤

配置DeviceA为源设备。

(1)   配置远程VLAN

DeviceA> enable

DeviceA# configure terminal

DeviceA(config)# vlan 7

DeviceA(config-vlan)# remote-span

DeviceA(config-vlan)# exit

(2)   配置源端口。

DeviceA(config)# monitor session 1 remote-source

DeviceA(config)# monitor session 1 source interface gigabitethernet 0/1 both

(3)   配置输出端口。

DeviceA(config)# monitor session 1 destination remote vlan 7 interface gigabitethernet 0/2 switch

(4)   配置回环口。

DeviceA(config)# interface gigabitethernet 0/2

DeviceA(config-if)# mac-loopback

DeviceA(config-if)# switchport access vlan 7

DeviceA(config-if)# exit

DeviceA(config)# interface range gigabitethernet 0/3-4

DeviceA(config-if-range)# switchport mode trunk

配置DeviceB为目的设备。

(1)   配置远程VLAN

DeviceB> enable

DeviceB# configure

DeviceB(config)# vlan 7

DeviceB(config-vlan)# remote-span

DeviceB(config-vlan)# exit

(2)   配置目的端口。

DeviceB(config)# monitor session 1 remote-destination

DeviceB(config)# monitor session 1 destination remote vlan 7 interface gigabitethernet 0/2 switch

DeviceB(config)# interface gigabitethernet 0/1

DeviceB(config-if)# switchport mode trunk

配置DeviceC为目的设备。

(1)   配置远程VLAN

DeviceC> enable

DeviceC# configure

DeviceC(config)# vlan 7

DeviceC(config-vlan)# remote-span

DeviceC(config-vlan)# exit

(2)   配置目的端口。

DeviceC(config)# monitor session 1 remote-destination

DeviceC(config)# monitor session 1 destination remote vlan 7 interface gigabitethernet 0/2 switch

DeviceC(config)# interface gigabitethernet 0/1

DeviceC(config-if)# switchport mode trunk

5.    验证配置结果

DeviceA上通过show monitor命令查看镜像源设备配置结果。

DeviceA# show monitor

sess-num: 1

span-type: SOURCE_SPAN

src-intf:

GigabitEthernet 0/1   frame-type Both

dest-intf:

GigabitEthernet 0/2

Remote vlan 7

mtp_switch on

DeviceBDeviceC中通过show monitor命令查看镜像目的设备配置结果。以DeviceB为例说明。

DeviceB# show monitor

sess-num: 1

span-type: DEST_SPAN

dest-intf:

GigabitEthernet 0/2

Remote vlan 7

mtp_switch on

6.    配置文件

l  DeviceA的配置文件

hostname DeviceA

!

vlan 7

!

 remote-span

!

interface GigabitEthernet 0/2

 mac-loopback

 switchport access vlan 7

!

interface GigabitEthernet 0/3

switchport mode trunk

interface GigabitEthernet 0/4

switchport mode trunk

!

monitor session 1 remote-source

monitor session 1 source interface GigabitEthernet 0/1 both

monitor session 1 destination remote vlan 7 interface GigabitEthernet0/2 switch

!

end

l  DeviceB的配置文件

hostname DeviceB

!

vlan 7

 remote-span

!

interface GigabitEthernet 0/1

 switchport mode trunk

!

monitor session 1 remote-destination

monitor session 1 destination remote vlan 7 interface GigabitEthernet0/2 switch

!

end

l  DeviceC的配置文件

hostname Device

!

vlan 7

 remote-span

!

interface GigabitEthernet 0/1

 switchport mode trunk

 !

monitor session 1 remote-destination

monitor session 1 destination remote vlan 7 interface GigabitEthernet 0/2 switch

!

end

7.    常见错误

l  源设备、中间设备、目的设备均要配置远程VLANVID必须一致。

l  带宽大的端口被镜像到带宽小的端口可能会造成丢包。

3  ERSPAN基本功能配置举例

1.    组网需求

1-8中所示。网管希望通过网络分析仪对DeviceADeviceC的流量进行监控。其中对于DeviceA,监控双向数据流;对于DeviceC,仅监控部分发送到Device的报文。为了合理利用资源,对监控报文进行采样,采样率为1000

2.    组网图

图1-8     ERSPAN配置举例组网图

 

3.    配置要点

l  配置各设备之间三层路由可达。

l  配置DeviceB为源设备。GigabitEthernet 0/1GigabitEthernet 0/2均为源端口,监控GigabitEthernet 0/1的双向数据报文,对于GigabitEthernet 0/2的报文,仅镜像目的IP2.1.1.1的报文,GigabitEthernet 0/3为镜像报文出口。

l  配置镜像报文的采样率为1000

4.    配置步骤

配置DeviceB的地址。

DeviceB> enable

DeviceB# configure terminal

DeviceB(config)# interface gigabitethernet 0/1

DeviceB(config-if-GigabitEthernet 0/1)# ip address 1.1.1.1 255.255.255.0

DeviceB(config-if-GigabitEthernet 0/1)# exit

DeviceB(config)# interface gigabitethernet 0/2

DeviceB(config-if-GigabitEthernet 0/1)# ip address 2.1.1.1 255.255.255.0

DeviceB(config-if-GigabitEthernet 0/1)# exit

DeviceB(config)# interface gigabitethernet 0/3

DeviceB(config-if-GigabitEthernet 0/1)# ip address 13.1.1.1 255.255.255.0

DeviceB(config-if-GigabitEthernet 0/1)# exit

配置DeviceA的地址。

DeviceA> enable

DeviceA# configure terminal

DeviceA(config)# interface gigabitethernet 0/1

DeviceA(config-if-GigabitEthernet 0/1)# ip address 1.1.1.2 255.255.255.0

DeviceA(config-if-GigabitEthernet 0/1)# exit

配置DeviceC地址。

DeviceC> enable

DeviceC# configure terminal

DeviceC(config)# interface gigabitethernet 0/1

DeviceC(config-if-GigabitEthernet 0/1)# ip address 2.1.1.2 255.255.255.0

DeviceC(config-if-GigabitEthernet 0/1)# exit

DeviceB上配置ACL

DeviceB(config)#access-list 1 permit host 1.1.1.1

创建ERSPAN Session 1,设置为源设备,并设置端口GigabitEthernet 0/1为源端口,镜像双向数据流,端口GigabitEthernet 0/2也为源端口,仅进行目的地址为1.1.1.1的报文。

DeviceB(config)# monitor session 1 erspan-source

DeviceB(config-mon-erspan-src)# source interface gigabitethernet 0/1 both

DeviceB(config-mon-erspan-src)# source interface gigabitethernet 0/2 rx acl acl1

DeviceB(config-mon-erspan-src)# origin ip address 10.1.1.2

DeviceB(config-mon-erspan-src)# destination ip address 3.1.1.2

开启镜像报文采用功能并配置采样率为1000

DeviceB(config-mon-erspan-src)# sample enable

DeviceB(config-mon-erspan-src)# sample rate 1000

5.    验证配置结果

验证DeviceBDeviceA之间三层可通。

DeviceB# ping 1.1.1.2

Sending 5, 100-byte ICMP Echoes to 1.1.1.2, timeout is 2 seconds:

 < press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/8 ms.

验证DeviceBDeviceC之间三层可通。

DeviceB# ping 2.1.1.2

Sending 5, 100-byte ICMP Echoes to 2.1.1.2, timeout is 2 seconds:

 < press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/8 ms.

验证DeviceB与网络分析仪之间三层可通。

DeviceB# ping 3.1.1.2

Sending 5, 100-byte ICMP Echoes to 3.1.1.2, timeout is 2 seconds:

 < press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/8 ms.

通过show access-lists命令查看ACL配置成功。

DeviceB# show access-lists

 

ip access-list standard 1

 10 permit host 1.1.1.1

通过show monitor命令查看配置结果,ERSPAN会话处于Active状态。

DeviceB# show monitor

sess-num: 1

span-type: ERSPAN_SOURCE

src-intf:

 GigabitEthernet 0/1     frame-type: Both    TX status: Active  RX status: Active 

src-intf:

 GigabitEthernet 0/2     frame-type: RX Only   Rx acl id: 1   

status: Active

original ip address: 2.1.1.2

destination ip address: 3.1.1.2

ip ttl: 64

ip dscp: 0

sample rate: 1000

vrf: default

6.    配置文件

l  DeviceA的配置文件

hostname DeviceA

!

interface GigabitEthernet 0/1

 ip address 1.1.1.2 255.255.255.0

!

end

l  DeviceC的配置文件

hostname DeviceC

!

interface GigabitEthernet 0/1

 ip address 2.1.1.2 255.255.255.0

!

end

l  DeviceB的配置文件

hostname DeviceB

!

ip access-list standard 1

 10 permit host 1.1.1.1

!

interface GigabitEthernet 0/1

 ip address 1.1.1.1 255.255.255.0

!

interface GigabitEthernet 0/2

 ip address 2.1.1.1 255.255.255.0

!

interface GigabitEthernet 0/3

 ip address 3.1.1.1 255.255.255.0

!

monitor session 1 erspan-source

 source interface gigabitEthernet 0/1 both

 source interface gigabitEthernet 0/2 rx acl acl1

 origin ip address 10.1.1.2

 destination ip address 3.1.1.2

 sample enable

 sample rate 1000

!

end

7.    常见错误

l  配置ERSPAN镜像的会话ID已经被配置了RSPANLOCAL SPAN

l  从源设备到目的设备的三层路由无法互通。

返回顶部

请选择服务项目
关闭咨询页
售前咨询 售前咨询
售前咨询
售后服务 售后服务
售后服务
意见反馈 意见反馈
意见反馈
更多联系方式