中文
登录
交换机
园区网交换机
数据中心与云计算交换机
行业精选交换系列
工业交换机
SDN
配件
所有技术解决方案
路由器
核心路由器
汇聚路由器
接入路由器
移动路由器
行业精选路由器系列
无线
放装型无线接入点
墙面型无线接入点
智分无线接入点
室外无线接入点
场景化无线
无线控制器
行业精选无线系列
无线管理与应用
云桌面
云终端系列
云主机系列
云桌面软件系列
配件系列
服务产品
安全
大数据安全平台
下一代防火墙
安全网关
检测管理安全
安全服务
安全云
所有技术解决方案
软件
身份管理
安全管理系列
运营管理系列
身份中台
所有技术解决方案
服务产品
基础实施服务
基础维护服务
运维管理服务
整网服务
安全服务
备件与扩容服务
培训与认证服务
官方商城
尊龙时凯睿易
体验中心
尊龙时凯AI应用
网络研讨会
首页 >服务与支持 >常见问题 >镜像是什么,如何配置?
随着网络的发展,对网络的高可用性的要求日益提高。当网络出现异常时,需要对网络节点或者设备的端口进行了数据流量分析以便网络能够快速恢复正常,但同时又要求不影响设备数据流量的正常转发。
镜像是将指定端口的报文复制到另一个连接有网络监测设备的端口的功能,实现了对可疑的网络节点或者设备端口进行数据流量分析,同时又不影响被监控设备的数据转发。镜像功能主要应用在网络监控和故障排查两种场景中,实现了监控网络信息安全和解决网络故障的目的。
源端口也称为被监控口,源端口上的数据流会被复制一份到目的端口,用于网络分析或故障排除。
目的端口也称为为监控口,与监控设备相连接的端口,将接收到的源端口报文转发到监控设备。
会话是一个逻辑上的概念,一个完整的会话由源端口和目的端口组成。
SPAN(Switch Port Analyzer,交换式端口分析器)也称为本地端口镜像或者本地镜像。指同一个镜像会话的源端口与目的端口在同一台设备上的镜像。
RSPAN(Remote Switch Port Analyzer,远程端口镜像)是SPAN的扩展,源端口和目标端口处于不同的设备。
ERSPAN(Encapsulated Remote Switch Port Analyzer,封装远程端口镜像)是RSPAN的扩展,实现了跨越交换或路由网络的多台设备的远程监控方法。
远程镜像VLAN是一种特殊的VLAN,该VLAN只传输镜像报文,不对正常的业务数据进行传输。
源设备上将镜像报文发送到中间设备或者目的设备的端口称为输出端口。
源设备是远程镜像角色之一,指源端口所在的设备,负责将源端口的报文复制一份到源设备的输出端口,传输给中间设备或目的设备。
目的设备远程镜像角色之一,指远程镜像目的端口所在的设备,负责将中间设备或者源设备接收到的镜像报文转发给监控设备。
中间设备是远程镜像角色之一,指处于源设备和目的设备之间的设备,负责将镜像报文传输给下一个中间设备或目的设备。如果源设备与目的设备直接相连,则不存在中间设备。
镜像数据流指被镜像的数据报文。镜像会话的数据流包含以下三种方向的数据流:
l 输入数据流
所有源端口上接收到的报文都将被复制一份到目的端口。在一个镜像会话中,可以监控一个或多个源端口的输入报文。
l 输出数据流
所有从源端口发送的报文都将复制一份到目的端口。在一个镜像会话中,可以监控一个或多个源端口的输出报文。
l 双向数据流
同时包含输入数据流和输出数据流。在一个镜像会话中,可监控一个或多个源端口的输入和输出方向的数据流。
如图1-6所示,通过适当的配置,网络分析仪能够监控DeviceA转发给DeviceB的所有数据流,监控来自DeviceB的特定数据流(如来自PC1和PC2的数据流)。
l 配置DeviceA的GigabitEthernet 0/1和GigabitEthernet 0/2属于VLAN 1。创建SVI 1,并配置SVI 1地址为10.10.10.10/24。
l 配置DeviceB的GigabitEthernet 0/1属于VLAN 1。创建SVI 1,并配置SVI 1地址为10.10.10.20/24。
l 配置PC1、PC2的地址分别为10.10.10.1/24和10.10.10.2/24。
l 配置DeviceA的本地镜像,指定端口GigabitEthernet 0/1和GigabitEthernet 0/2分别为镜像的源端口和目的端口。监控DeviceA转发给DeviceB的所有数据流,监控来自DeviceB的特定数据流。
# 配置DeviceA的GigabitEthernet 0/1和GigabitEthernet 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
# 配置DeviceB的GigabitEthernet 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
# 通过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
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
警告
当部署一对多端口镜像时,必须使用switchport trunk allowed vlan remove vlan-list命令裁剪掉各镜像设备上trunk类型的接口中广播的VLAN,否则trunk接口可能会被广播的流量占满导致业务中断。
如图1-7所示,网络分析仪可以通过远程镜像功能,实现在目的设备DeviceB和DeviceC上监控源设备DeviceA上的双向数据流。且设备之间均能正常交换数据。
l 配置DeviceA为源设备,配置远程镜像VLAN,配置端口GigabitEthernet 0/1为源端口,与目的设备相连的端口GigabitEthernet 0/3和GigabitEthernet 0/4为输出端口,配置GigabitEthernet 0/2接口为MAC回环口,用于实现一对多镜像的“反射”功能。配置输出端口可交换功能。
l DeviceB和DeviceC配置为目的设备,配置远程镜像VLAN,与源设备相连的端口GigabitEthernet 0/1作为源端口,配置Trunk端口,与网络分析仪相连的端口GigabitEthernet 0/2配置为镜像目的端口,并配置镜像目的端口可交换功能。
# 配置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
# 在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
# 在DeviceB和DeviceC中通过show monitor命令查看镜像目的设备配置结果。以DeviceB为例说明。
DeviceB# show monitor
sess-num: 1
span-type: DEST_SPAN
dest-intf:
GigabitEthernet 0/2
Remote vlan 7
mtp_switch on
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
l 源设备、中间设备、目的设备均要配置远程VLAN且VID必须一致。
l 带宽大的端口被镜像到带宽小的端口可能会造成丢包。
如图1-8中所示。网管希望通过网络分析仪对DeviceA和DeviceC的流量进行监控。其中对于DeviceA,监控双向数据流;对于DeviceC,仅监控部分发送到Device的报文。为了合理利用资源,对监控报文进行采样,采样率为1000。
l 配置各设备之间三层路由可达。
l 配置DeviceB为源设备。GigabitEthernet 0/1,GigabitEthernet 0/2均为源端口,监控GigabitEthernet 0/1的双向数据报文,对于GigabitEthernet 0/2的报文,仅镜像目的IP为2.1.1.1的报文,GigabitEthernet 0/3为镜像报文出口。
l 配置镜像报文的采样率为1000。
# 配置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
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
# 验证DeviceB与DeviceA之间三层可通。
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.
# 验证DeviceB与DeviceC之间三层可通。
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
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
l 配置ERSPAN镜像的会话ID已经被配置了RSPAN或LOCAL SPAN。
l 从源设备到目的设备的三层路由无法互通。