MQC 多数在QoS中应用,也可以用在策略路由中。
MQC是模块化QoS命令行,由三要素组成:流分类、流行为、流策略
流分类:traffic classifier
语法规则
[Huawei]traffic classifier name operator ?
and Rule of matching all of the statements
or Rule of matching one of the statements
默认规则为or
[Huawei-classifier-name]if-match acl 3001
[Huawei-classifier-name]if-match acl 3002
定义一个流分类,名字为name
if-match 为条件语句:
and 表示所有条件为“与”的关系,or 表示所有条件为“或”的关系。
流行为:traffic behavior
语法规则
流行为中可以定义很多属性,该篇只讲述策略路由中的应用
[Huawei]traffic behavior name
[Huawei-behavior-name]redirect ip-nexthop 10.1.1.1
定义一个流行为,名字为name
重定向下一跳的ip地址为10.1.1.1
流策略:traffic policy
语法规则
[Huawei]traffic policy name
[Huawei-trafficpolicy-name]classifier name behavior name
定义一个流策略,名字为name
将名字为name的流分类个名字为name的流行为做绑定
调用
[Huawei-GigabitEthernet0/0/0]traffic-policy name inbound
在接口上调用名字为 name 的traffic-policy,应用在接口的入方向
实验案例
实验拓扑
实验要求:
R1上的 1.1.1.1 ping 访问R3上的 14.114.114.114
R1上的 2.2.2.2 ping 访问R4上的 114.114.114.114
R1上的 1.1.1.1 telnet 访问R4上的 114.114.114.114
R1上的 2.2.2.2 telnet 访问R3上的 114.114.114.114
实验步骤:
1.实现图中路由全通,请自行配置
2.定义acl(acl规则不做解释)
R2
#
acl number 3001
rule 5 permit icmp source 1.1.1.1 0 destination 114.114.114.114 0
acl number 3002
rule 5 permit tcp source 1.1.1.1 0 destination 114.114.114.114 0 destination-port eq telnet
acl number 3003
rule 5 permit icmp source 2.2.2.2 0 destination 114.114.114.114 0
acl number 3004
rule 5 permit tcp source 2.2.2.2 0 destination 114.114.114.114 0 destination-port eq telnet
#
3.定义流分类
R2
#
traffic classifier 3001 operator or
if-match acl 3001
traffic classifier 3002 operator or
if-match acl 3002
traffic classifier 3003 operator or
if-match acl 3003
traffic classifier 3004 operator or
if-match acl 3004
#
4.定义流行为
R2
#
traffic behavior toR3
redirect ip-nexthop 10.0.23.3
traffic behavior toR4
redirect ip-nexthop 10.0.24.4
#
5.定义流策略,将流分类和流行为做绑定
R2
#
traffic policy test
classifier 3001 behavior toR3
classifier 3004 behavior toR3
classifier 3002 behavior toR3
classifier 3003 behavior toR3
#
6.调用
[R2-GigabitEthernet0/0/0]traffic-policy test inbound
7.测试
在R2上 g0/0/1 g0/0/2 接口分别抓包进行测试
本实验详细解读了MQC在策略路由中的应用,了解其中对应关系,则可以灵活应用在实际案例中!