您订阅的产品有更新,请实时查阅
审查详情首页 >服务与支持 >常见问题 >镜像是什么,怎样设置?
随着网络的生长,对网络的高可用性的要求日益提高。当网络泛起异常时,需要对网络节点或者装备的端口举行了数据流量剖析以便网络能够快速恢复正常,但同时又要求不影响装备数据流量的正常转发。
镜像是将指定端口的报文复制到另一个毗连有网络监测装备的端口的功效,实现了对可疑的网络节点或者装备端口举行数据流量剖析,同时又不影响被监控装备的数据转发。镜像功效主要应用在网络监控和故障排查两种场景中,实现了监控网络信息清静息争决网络故障的目的。
源端口也称为被监控口,源端口上的数据流会被复制一份到目的端口,用于网络剖析或故障扫除。
目的端口也称为为监控口,与监控装备相毗连的端口,将吸收到的源端口报文转发到监控装备。
会话是一个逻辑上的看法,一个完整的会话由源端口和目的端口组成。
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 从源装备到目的装备的三层路由无法互通。