您订阅的产品有更新,请实时查阅
查看详情首页 >服务与支持 >常见问题 >镜像是什么,若何配置?
随着网络的发展,对网络的高可用性的要求日益提高。当网络出现异常时,必要对网络节点或者设备的端口进行了数据流量分析以便网络可能急剧复原正常,但同时又要求不影响设备数据流量的正常转发。
镜像是将指定端口的报文复造到另一个衔接有网络监测设备的端口的职能,实现了对可疑的网络节点或者设备端口进行数据流量分析,同时又不影响被监控设备的数据转发。镜像职能重要利用在网络监控和故障排查两种场景中,实现了监控网络信息安全和解决网络故障的主张。
源端口也称为被监控口,源端口上的数据流会被复造一份到主张端口,用于网络分析或故障排除。
主张端口也称为为监控口,与监控设备相衔接的端口,将接管到的源端口报文转发到监控设备。
会话是一个逻辑上的概想,一个齐全的会话由源端口和主张端口组成。
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 从源设备到主张设备的三层路由无法互通。