04-H3C_镜像典型配置举例
本章节下载: 04-H3C_镜像典型配置举例 (960.65 KB)
资料版本:6W101-20230905
产品版本:Release 7743P06
Copyright © 2022-2023 新华三技术有限公司 版权所有,保留一切权利。 非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,并不得以任何形式传播。 除新华三技术有限公司的商标外,本手册中出现的其它公司的商标、产品标识及商品名称,由各自权利人拥有。 本文档中的信息可能变动,恕不另行通知。 |
目 录
本文介绍了端口镜像和流镜像的典型配置举例。
本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。
本文假设您已了解镜像特性。
如图1所示,某公司内部各部门使用不同网段的IP地址,其中研发部使用10.1.1.0/24网段,市场部使用12.1.1.0/24网段。现要求通过配置本地端口镜像功能,使用数据监测设备对研发部和市场部访问Internet的流量以及两个部门之间互访的流量进行监控。
· 本地镜像组需要配置源端口、目的端口才能生效。其中目的端口不能是现有镜像组的成员端口。
· 目的端口收到的报文包括复制自源端口的报文和来自其他端口的正常转发报文。为了保证数据监测设备只对源端口的报文进行分析,请将目的端口只用于端口镜像,不作其他用途。
# 创建VLAN10,并向VLAN 10中添加端口GigabitEthernet1/0/1。
<DeviceA> system-view
[DeviceA] vlan 10
[DeviceA-vlan10] port GigabitEthernet 1/0/1
[DeviceA-vlan10] quit
# 创建VLAN20,并向VLAN 20中添加端口GigabitEthernet1/0/2。
[DeviceA] vlan 20
[DeviceA-vlan20] port GigabitEthernet 1/0/2
[DeviceA-vlan20] quit
# 创建VLAN30,并向VLAN 20中添加端口GigabitEthernet1/0/4。
[DeviceA] vlan 30
[DeviceA-vlan30] port GigabitEthernet 1/0/4
[DeviceA-vlan30] quit
# 配置接口Vlan-interface10的IP地址为10.1.1.1。
[DeviceA] interface vlan-interface 10
[DeviceA-Vlan-interface10] ip address 10.1.1.1 24
[DeviceA-Vlan-interface10] quit
# 请参考以上方法配置图1中其他接口的IP地址,配置步骤这里省略。
# 创建本地镜像组。
[DeviceA] mirroring-group 1 local
# 将GigabitEthernet1/0/1和GigabitEthernet1/0/2配置为镜像源端口,对这两个端口接收的报文进行镜像。
[DeviceA] mirroring-group 1 mirroring-port GigabitEthernet 1/0/1 GigabitEthernet 1/0/2 inbound
# 将GigabitEthernet1/0/3配置为镜像目的端口。
[DeviceA] mirroring-group 1 monitor-port GigabitEthernet 1/0/3
# 关闭目的端口GigabitEthernet1/0/3上的生成树协议。
[DeviceA] interface GigabitEthernet 1/0/3
[DeviceA-GigabitEthernet1/0/3] undo stp enable
[DeviceA-GigabitEthernet1/0/3] quit
# 在完成上述配置后,在DeviceA上显示镜像组1的配置信息。
[DeviceA] display mirroring-group 1
Mirroring group 1:
Type: Local
Status: Active
Mirroring port:
GigabitEthernet1/0/1 Inbound
GigabitEthernet1/0/2 Inbound
Monitor port: GigabitEthernet1/0/3
# 以研发部某台主机10.1.1.2通过ping方式访问56.56.56.6为例,进行镜像测试,数据监测设备的抓包数据如图2所示。
图2 Wireshark的抓包数据
以上抓包信息表明,配置的本地镜像功能生效,数据监测设备可以成功对需要监控的流量进行监控。
#
mirroring-group 1 local
#
vlan 10
#
vlan 20
#
vlan 30
#
interface Vlan-interface10
ip address 10.1.1.1 255.255.255.0
#
interface Vlan-interface20
ip address 12.1.1.1 255.255.255.0
#
interface Vlan-interface30
ip address 56.56.56.5 255.255.255.0
#
interface GigabitEthernet1/0/1
port access vlan 10
mirroring-group 1 mirroring-port inbound
#
interface GigabitEthernet1/0/2
port access vlan 20
mirroring-group 1 mirroring-port inbound
#
interface GigabitEthernet1/0/3
undo stp enable
mirroring-group 1 monitor-port
#
interface GigabitEthernet1/0/4
port access vlan 30
#
如图3所示,某公司内部各部门通过二层网络连接到核心设备Device A,各部门使用不同网段的IP地址,其中研发部使用10.1.1.0/24网段,市场部使用12.1.1.0/24网段。现要求通过配置二层远程端口镜像功能,使用数据监测设备对研发部发送的报文进行监控。
· 为确保源设备与目的设备之间的镜像报文可以二层转发,中间设备连接到源设备和目的设备方向的端口上需允许远程镜像VLAN通过。
· 建议用户先配目的设备,再配中间设备,最后配源设备,以保证镜像流量的正常转发。
配置远程端口镜像的目的设备和源设备时均需要注意:
· 配置远程镜像VLAN时:
¡ 要求该VLAN为静态VLAN并预先创建。
¡ 要求该VLAN不用做其他用途,仅用于远程镜像功能。
¡ 要求该VLAN只能被一个远程源镜像组使用。
· 源设备和目的设备上的远程镜像组必须使用相同的远程镜像VLAN。
配置远程端口镜像的目的设备时需要注意:
· 目的端口不能是现有镜像组的成员端口。
· 目的端口不用做其他用途,仅用于端口镜像。
配置远程端口镜像的源设备时需要注意:
· 请不要将源端口加入到远程镜像VLAN中,否则会影响镜像功能的正常使用。
· 请不要在出端口上配置下列功能:生成树协议、802.1X、静态ARP和MAC地址学习,否则会影响镜像功能的正常使用。
# 创建业务VLAN 2和VLAN 3。
<DeviceA> system-view
[DeviceA] vlan 2 to 3
# 创建VLAN 2接口和VLAN 3接口并配置IP地址作为相应VLAN的网关。
[DeviceA] interface vlan-interface 2
[DeviceA-Vlan-interface2] ip address 10.1.1.1 24
[DeviceA-Vlan-interface2] quit
[DeviceA] interface vlan-interface 3
[DeviceA-Vlan-interface3] ip address 12.1.1.1 24
[DeviceA-Vlan-interface3] quit
# 配置端口GigabitEthernet 1/0/1的端口类型为Trunk端口,允许业务VLAN 2、VLAN 3和镜像VLAN 5的报文通过。
<DeviceA> system-view
[DeviceA] interface GigabitEthernet 1/0/1
[DeviceA-GigabitEthernet1/0/1] port link-type trunk
[DeviceA-GigabitEthernet1/0/1] port trunk permit vlan 2 3 5
[DeviceA-GigabitEthernet1/0/1] quit
# 配置端口GigabitEthernet1/0/2的端口类型为Trunk端口,允许业务VLAN 2和镜像VLAN 5的报文通过。
[DeviceA] interface GigabitEthernet 1/0/2
[DeviceA-GigabitEthernet1/0/2] port link-type trunk
[DeviceA-GigabitEthernet1/0/2] port trunk permit vlan 2 5
[DeviceA-GigabitEthernet1/0/2] quit
# 创建远程目的镜像组1。
[DeviceA] mirroring-group 1 remote-destination
# 创建VLAN 5作为远程镜像VLAN。
[DeviceA] vlan 5
[DeviceA-vlan5] quit
# 为远程目的镜像组1配置远程镜像VLAN为VLAN 5,及配置连接数据监测设备的端口GigabitEthernet 1/0/3为目的端口。
[DeviceA] mirroring-group 1 remote-probe vlan 5
[DeviceA] mirroring-group 1 monitor-port GigabitEthernet 1/0/3
# 将镜像目的端口加入远程镜像VLAN。将镜像数据发送给监测设备时,不需要携带远程镜像VLAN的VLAN Tag,因此将该端口配置为Access端口。
[DeviceA] interface GigabitEthernet 1/0/3
[DeviceA-GigabitEthernet1/0/3] port access vlan 5
# 关闭目的端口GigabitEthernet1/0/3上的生成树协议。
[DeviceA-GigabitEthernet1/0/3] undo stp enable
[DeviceA-GigabitEthernet1/0/3] quit
# 创建业务VLAN 2和VLAN 3。
<DeviceB> system-view
[DeviceB] vlan 2 to 3
# 创建VLAN 5作为远程镜像VLAN。
[DeviceB] vlan 5
[DeviceB-vlan5] quit
# 配置端口GigabitEthernet 1/0/1的端口类型为Trunk端口,允许业务VLAN 2、VLAN 3和镜像VLAN 5的报文通过。
[DeviceB] interface GigabitEthernet 1/0/1
[DeviceB-GigabitEthernet1/0/1] port link-type trunk
[DeviceB-GigabitEthernet1/0/1] port trunk permit vlan 2 3 5
[DeviceB-GigabitEthernet1/0/1] quit
# 配置端口GigabitEthernet 1/0/2的端口类型为Trunk端口,允许业务VLAN 2、VLAN 3和镜像VLAN 5的报文通过。
[DeviceB] interface GigabitEthernet 1/0/2
[DeviceB-GigabitEthernet1/0/2] port link-type trunk
[DeviceB-GigabitEthernet1/0/2] port trunk permit vlan 2 3 5
[DeviceB-GigabitEthernet1/0/2] quit
# 创建业务VLAN 2和VLAN 3。
<DeviceC> system-view
[DeviceC] vlan 2 to 3
# 将端口GigabitEthernet 1/0/1加入VLAN 2。
[DeviceC] interface GigabitEthernet 1/0/1
[DeviceC-GigabitEthernet1/0/1] port access vlan 2
[DeviceC-GigabitEthernet1/0/1] quit
# 将端口GigabitEthernet 1/0/2加入VLAN 3。
[DeviceC] interface GigabitEthernet 1/0/2
[DeviceC-GigabitEthernet1/0/2] port access vlan 3
[DeviceC-GigabitEthernet1/0/2] quit
# 创建远程源镜像组1。
[DeviceC] mirroring-group 1 remote-source
# 创建VLAN 5作为远程镜像VLAN。
[DeviceC] vlan 5
[DeviceC-vlan5] quit
# 配置远程源镜像组1的远程镜像VLAN为VLAN 5,源端口为GigabitEthernet1/0/1,出端口为GigabitEthernet1/0/3。
[DeviceC] mirroring-group 1 remote-probe vlan 5
[DeviceC] mirroring-group 1 mirroring-port GigabitEthernet 1/0/1 inbound
[DeviceC] mirroring-group 1 monitor-egress GigabitEthernet 1/0/3
# 配置端口GigabitEthernet 1/0/3的端口类型为Trunk端口,允许业务VLAN 2、VLAN 3和镜像VLAN 5的报文通过。
[DeviceC] interface GigabitEthernet 1/0/3
[DeviceC-GigabitEthernet1/0/3] port link-type trunk
[DeviceC-GigabitEthernet1/0/3] port trunk permit vlan 2 3 5
[DeviceC-GigabitEthernet1/0/3] quit
# 关闭出端口GigabitEthernet1/0/3上的生成树协议、MAC地址学习功能。
[DeviceC-GigabitEthernet1/0/3] undo stp enable
[DeviceC-GigabitEthernet1/0/3] undo mac-address mac-learning enable
[DeviceC-GigabitEthernet1/0/3] quit
# 创建业务VLAN 2。
<DeviceD> system-view
[DeviceD] vlan 2
[DeviceD-vlan2] quit
# 将端口GigabitEthernet 1/0/1加入VLAN 2。
[DeviceD] interface GigabitEthernet 1/0/1
[DeviceD-GigabitEthernet1/0/1] port access vlan 2
[DeviceD-GigabitEthernet1/0/1] quit
# 创建远程源镜像组1。
[DeviceD] mirroring-group 1 remote-source
# 创建VLAN 5作为远程镜像VLAN。
[DeviceD] vlan 5
[DeviceD-vlan5] quit
# 配置远程源镜像组1的远程镜像VLAN为VLAN 5,对源端口GigabitEthernet1/0/1入方向进行镜像,出端口为GigabitEthernet1/0/2。
[DeviceD] mirroring-group 1 remote-probe vlan 5
[DeviceD] mirroring-group 1 mirroring-port GigabitEthernet 1/0/1 inbound
[DeviceD] mirroring-group 1 monitor-egress GigabitEthernet 1/0/2
# 配置端口GigabitEthernet 1/0/2的端口类型为Trunk端口,允许业务VLAN 2和镜像VLAN 5的报文通过。
[DeviceD] interface GigabitEthernet 1/0/2
[DeviceD-GigabitEthernet1/0/2] port link-type trunk
[DeviceD-GigabitEthernet1/0/2] port trunk permit vlan 2 5
# 关闭出端口GigabitEthernet1/0/2上的生成树协议、MAC地址学习功能。
[DeviceD-GigabitEthernet1/0/2] undo stp enable
[DeviceD-GigabitEthernet1/0/2] undo mac-address mac-learning enable
[DeviceD-GigabitEthernet1/0/2] quit
# 在完成上述配置后,在DeviceC上显示镜像组1的配置信息。
[DeviceC] display mirroring-group 1
Mirroring group 1:
Type: Remote source
Status: Active
Mirroring port:
GigabitEthernet1/0/1 Inbound
Monitor egress port: GigabitEthernet1/0/3
Remote probe VLAN: 5
# 在DeviceA上显示镜像组1的配置信息。
[DeviceA] display mirroring-group 1
Mirroring group 1:
Type: Remote destination
Status: Active
Monitor port: GigabitEthernet1/0/3
Remote probe VLAN: 5
# 以研发部某台主机10.1.1.2通过ping方式访问市场部某台主机12.1.1.2为例,进行镜像测试,数据监测设备的抓包数据如图4所示。
图4 Wireshark的抓包数据
以上抓包信息表明,配置的二层远程端口镜像功能生效,数据监测设备可以成功对对研发部发送的报文进行监控。
· 设备Device A:
#
mirroring-group 1 remote-destination
mirroring-group 1 remote-probe vlan 5
#
vlan 2 to 3
#
vlan 5
#
interface Vlan-interface2
ip address 10.1.1.1 255.255.255.0
#
interface Vlan-interface3
ip address 12.1.1.1 255.255.255.0
#
interface GigabitEthernet1/0/1
port link-type trunk
port trunk permit vlan 1 to 3 5
#
interface GigabitEthernet1/0/2
port link-type trunk
port trunk permit vlan 1 to 2 5
#
interface GigabitEthernet1/0/3
port access vlan 5
undo stp enable
mirroring-group 1 monitor-port
#
· 设备Device B:
#
vlan 2 to 3
#
vlan 5
#
interface GigabitEthernet1/0/1
port link-type trunk
port trunk permit vlan 1 to 3 5
#
interface GigabitEthernet1/0/2
port link-type trunk
port trunk permit vlan 1 to 3 5
#
· 设备Device C:
#
mirroring-group 1 remote-source
mirroring-group 1 remote-probe vlan 5
#
vlan 2 to 3
#
vlan 5
#
interface GigabitEthernet1/0/1
port access vlan 2
mirroring-group 1 mirroring-port inbound
#
interface GigabitEthernet1/0/2
port access vlan 3
#
interface GigabitEthernet1/0/3
port link-type trunk
port trunk permit vlan 1 to 3 5
mirroring-group 1 monitor-egress
· 设备Device D:
#
mirroring-group 1 remote-source
mirroring-group 1 remote-probe vlan 5
#
vlan 2
#
vlan 5
#
interface GigabitEthernet1/0/1
port access vlan 2
mirroring-group 1 mirroring-port inbound
#
interface GigabitEthernet1/0/2
port link-type trunk
port trunk permit vlan 1 to 2 5
mirroring-group 1 monitor-egress
如图5所示,某公司内部各部门使用不同网段的IP地址,其中研发部使用10.1.1.0/24网段,市场部使用12.1.1.0/24网段,公共服务器群使用14.1.1.0/24网段。现要求通过配置本地流镜像功能,使用数据监测设备对以下两种数据进行监控:
· 研发部主机访问Internet时发送的HTTP流量。
· 在工作日的非工作时间段(工作时间段为8:30至18:00),市场部从公共服务器群接收到的报文。
配置本地流镜像功能时,首先需要根据报文特点制定需要镜像报文的分类规则,然后,在设备上对以上分类的报文采用镜像到指定端口(连接数据监测设备的端口)的动作,即可以实现组网需求。
(1) 配置Device A的接口IP地址。
# 创建VLAN10,并向VLAN 10中添加端口GigabitEthernet1/0/1。
<DeviceA> system-view
[DeviceA] vlan 10
[DeviceA-vlan10] port GigabitEthernet 1/0/1
[DeviceA-vlan10] quit
# 创建VLAN20,并向VLAN 20中添加端口GigabitEthernet1/0/3。
[DeviceA] vlan 20
[DeviceA-vlan20] port GigabitEthernet 1/0/3
[DeviceA-vlan20] quit
# 配置接口Vlan-interface10的IP地址为35.35.35.5。
[DeviceA] interface vlan-interface 10
[DeviceA-Vlan-interface10] ip address 35.35.35.5 24
[DeviceA-Vlan-interface10] quit
# 配置接口Vlan-interface20的IP地址为56.56.56.5。
[DeviceA] interface vlan-interface 20
[DeviceA-Vlan-interface20] ip address 56.56.56.5 24
[DeviceA-Vlan-interface20] quit
# 请参考以上方法配置图5中其他接口的IP地址,配置步骤这里省略。
(2) 定义对研发部上网流量进行镜像的QoS策略
# 创建ACL 3000,匹配研发部的上网流量。
[DeviceA] acl number 3000
[DeviceA-acl-adv-3000] rule permit tcp destination-port eq 80 source 10.1.1.0 0.0.0.255
[DeviceA-acl-adv-3000] quit
# 创建流分类classifier_research,匹配ACL 3000。
[DeviceA] traffic classifier classifier_research
[DeviceA-classifier-classifier_research] if-match acl 3000
[DeviceA-classifier-classifier_research] quit
# 定义流行为behavior_research,动作为镜像至端口GigabitEthernet 1/0/2。
[DeviceA] traffic behavior behavior_research
[DeviceA-behavior-behavior_research] mirror-to interface GigabitEthernet 1/0/2
[DeviceA-behavior-behavior_research] quit
# 定义策略policy_research,为类classifier_research指定流行为behavior_research。
[DeviceA] qos policy policy_research
[DeviceA-qospolicy-policy_research] classifier classifier_research behavior behavior_research
[DeviceA-qospolicy-policy_research] quit
(3) 定义对市场部主机从公共服务器获取的数据进行镜像的QoS策略
# 定义两个非工作时间段,分别为工作日的0:00至8:30和18:00至24:00,并分别命名为“off-work1”和“off-work2”。
[DeviceA] time-range off-work1 0:00 to 8:30 working-day
[DeviceA] time-range off-work2 18:00 to 24:00 working-day
# 创建ACL 3001,通过两条规则来匹配公共服务器在非工作时间段发往市场部主机的数据。
[DeviceA] acl number 3001
[DeviceA-acl-adv-3001] rule permit ip destination 12.1.1.0 0.0.0.255 source 14.1.1.0 0.0.0.255 time-range off-work1
[DeviceA-acl-adv-3001] rule permit ip destination 12.1.1.0 0.0.0.255 source 14.1.1.0 0.0.0.255 time-range off-work2
[DeviceA-acl-adv-3001] quit
# 创建流分类classifier_market,匹配ACL 3001。
[DeviceA] traffic classifier classifier_market
[DeviceA-classifier-classifier_market] if-match acl 3001
[DeviceA-classifier-classifier_market] quit
# 定义流行为behavior_market,动作为镜像至端口GigabitEthernet 1/0/2。
[DeviceA] traffic behavior behavior_market
[DeviceA-behavior-behavior_market] mirror-to interface GigabitEthernet 1/0/2
[DeviceA-behavior-behavior_market] quit
# 定义策略policy_market,为类classifier_market指定流行为behavior_market。
[DeviceA] qos policy policy_market
[DeviceA-qospolicy-policy_market] classifier classifier_market behavior behavior_market
[DeviceA-qospolicy-policy_market] quit
(4) 应用QoS策略
# 将policy_research策略应用到GigabitEthernet1/0/1端口的入方向。
[DeviceA] interface GigabitEthernet 1/0/1
[DeviceA-GigabitEthernet1/0/1] qos apply policy policy_research inbound
[DeviceA-GigabitEthernet1/0/1] quit
# 将policy_market策略应用到GigabitEthernet1/0/3端口的入方向。
[DeviceA] interface GigabitEthernet 1/0/3
[DeviceA-GigabitEthernet1/0/3] qos apply policy policy_market inbound
[DeviceA-GigabitEthernet1/0/3] quit
# 在完成上述配置后,在DeviceA上验证流镜像的配置信息。
[DeviceA] display qos policy interface
Interface: GigabitEthernet1/0/1
Direction: Inbound
Policy: policy_research
Classifier: classifier_research
Operator: AND
Rule(s) :
If-match acl 3000
Behavior: behavior_research
Mirroring:
Mirror to the interface: GigabitEthernet1/0/2
Interface: GigabitEthernet1/0/3
Direction: Inbound
Policy: policy_market
Classifier: classifier_market
Operator: AND
Rule(s) :
If-match acl 3001
Behavior: behavior_market
Mirroring:
Mirror to the interface: GigabitEthernet1/0/2
# 以研发部某台主机10.1.1.2 通过Telnet方式访问46.46.46.4的80端口为例,进行镜像测试,数据监测设备的抓包数据如图6所示。
图6 HTTP流量的Wireshark抓包数据
以上抓包信息表明,数据监测设备可以成功对研发部主机访问Internet时发送的HTTP流量进行监控。
# 以市场部某台主机12.1.1.2在非工作时段通过ping方式访问服务器14.1.1.2为例,进行镜像测试,数据监测设备的抓包数据如图7所示。
以上抓包信息表明,在工作日的非工作时间段(工作时间段为8:30至18:00),数据监测设备可以成功对市场部从公共服务器群接收到的报文进行监控。
#
vlan 10
#
vlan 20
#
time-range off-work1 00:00 to 08:30 working-day
time-range off-work2 18:00 to 24:00 working-day
#
acl number 3000
rule 0 permit tcp source 10.1.1.0 0.0.0.255 destination-port eq www
#
acl number 3001
rule 0 permit ip source 14.1.1.0 0.0.0.255 destination 12.1.1.0 0.0.0.255 time-range off-work1
rule 5 permit ip source 14.1.1.0 0.0.0.255 destination 12.1.1.0 0.0.0.255 time-range off-work2
#
traffic classifier classifier_research operator and
if-match acl 3000
#
traffic classifier classifier_market operator and
if-match acl 3001
#
traffic behavior behavior_research
mirror-to interface GigabitEthernet1/0/2
#
traffic behavior behavior_market
mirror-to interface GigabitEthernet1/0/2
#
qos policy policy_research
classifier classifier_research behavior behavior_research
#
qos policy policy_market
classifier classifier_market behavior behavior_market
#
interface Vlan-interface10
ip address 35.35.35.5 255.255.255.0
#
interface Vlan-interface20
ip address 56.56.56.5 255.255.255.0
#
interface GigabitEthernet1/0/1
port access vlan 10
qos apply policy policy_research inbound
#
interface GigabitEthernet1/0/3
port access vlan 20
qos apply policy policy_market inbound
#
· H3C S5130S-EI-G系列交换机 网络管理和监控配置指导-R7743PXX
· H3C S5130S-EI-G系列交换机 网络管理和监控命令参考-R7743PXX
不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!