当前位置:网站首页>2022-07-02 网工进阶(十五)路由策略-Route-Policy特性、策略路由(Policy-Based Routing)、MQC(模块化QoS命令行)
2022-07-02 网工进阶(十五)路由策略-Route-Policy特性、策略路由(Policy-Based Routing)、MQC(模块化QoS命令行)
2022-07-03 19:21:00 【鹅一只】
Route-Policy特性
if-match子句
没有if-match子句代表匹配所有。
if-match子句条件不成立代表跳过节点。
Route-Policy匹配规则
在Route-Policy中调用的匹配工具(ACL、p-prefix)中的permit代表意思为“抓取、命中”;而deny代表意思为“忽略、跳过”。
Route-Policy中的匹配模式permit代表意思为“允许通过”;而deny代表意思为“拒绝通过”。
举例说明
假设Route-Policy的过滤范围中有2条路由。
第一个节点调用的匹配工具的规则为:第1条permit、第2条deny。
当第一个节点匹配模式为permit时:会对第1条采 取放行,并执行apply子句。把第2条交给后面的节点处理,因为第1条已经被“抓取”,就不会再次被后面的节点“抓取”。如果后面的节点中的匹配工具permit了第2条,处理方式同第1条。
当第一个节点匹配模式为deny时:会对第1条采取拒绝通行的处理方式。把第2条交给后面的节点处理,因为第1条已经被“抓取”,就不会再次被后面的节点“抓取”。如果后面的节点中的匹配工具permit了第2条,将会采取放行,并执行apply子句。
注1:Route-Policy的匹配模式为deny的情况下不会执行apply子句。
注2:通过观察实验结果,如果笔者没有猜错,匹配工具ip-prefix的index 和 策略工具Route-Policy的node 与 匹配工具ACL的rule一样在末尾都包含一条拒绝所有通过的隐藏规则。
策略路由(Policy-Based Routing)
PBR(Policy-Based Routing,策略路由):PBR使得网络设备不仅能够基于报文的目的IP地址进行数据转发,更能基于其他元素进行数据转发,例如源IP地址、源MAC地址、目的MAC地址、源端口号、目的端口号、VLAN-ID等等。
用户还可以使用ACL匹配特定的报文,然后针对该ACL进行PBR部署。
若设备部署了PBR,则被匹配的报文优先根据PBR的策略进行转发,即PBR策略的优先级高于传统路由表。
PBR结构
PBR与Route-Policy类似,由多个节点组成,每个节点由匹配条件(条件语句)和执行动作(执行语句)组成。
每个节点内可包含多个条件语句。
节点内的多个条件语句之间的关系为“与”,即匹配所有条件语句才会执行本节点内的动作。
节点之间的关系为“或”,PBR根据节点编号从小到大顺序执行,匹配当前节点将不会继续向下匹配。

策略路由(PBR)与路由策略区别
| 名称 | 操作对象 | 描述 |
| 路由策略 | 路由信息 | 路由策略是一套用于对路由信息进行过滤、属性设置等操作的方法,通过对路由的操作或控制,来影响数据报文的转发路径 |
| 策略路由 | 数据报文 | PBR直接对数据报文进行操作,通过多种手段匹配感兴趣的报文,然后执行丢弃或强制转发路径等操作 |
PBR的分类
接口PBR
接口PBR只对转发的报文起作用,对本地始发的报文无效。
接口PBR调用在接口下,对接口的入方向报文生效。缺省情况下,设备按照路由表的下一跳进行报文转发,如果配置了接口PBR,则设备按照接口PBR指定的下一跳进行转发。
本地PBR
本地PBR对本地始发的流量生效,如:本地始发的ICMP报文。
本地PBR在系统视图调用。
相关命令
创建PBR
[R1]policy-based-route 10 permit node 10设置匹配条件(匹配ACL)
[R1-policy-based-route-10-10]if-match acl 2000设置匹配条件(匹配报文字节长度范文)
[R1-policy-based-route-10-10]if-match packet-length 0 100设置匹配动作(指定下一跳)
[R1-policy-based-route-10-10]apply ip-address next-hop 10.1.1.3设置匹配动作(指定出接口,路由优先级高于指定下一跳)
[R1-policy-based-route-10-10]apply output-interface GigabitEthernet 0/0/1调用到全局(本地)PBR
[R1]ip local policy-based-route 10调用到接口PBR
[R1-GigabitEthernet0/0/0]ip policy-based-route 10MQC
MQC(Modular QoS Command-Line Interface,模块化QoS命令行)是指通过将具有某类共同特征的数据流划分为一类,并为同一类数据流提供相同的服务,也可以对不同类的数据流提供不同的服务。
MQC包含三个要素:流分类(traffic classifier)、流行为(traffic behavior)和流策略(traffic policy)。
流分类:配置流分类,用于匹配感兴趣数据流。可基于VLAN Tag、DSCP、ACL规则等。
流行为:将感兴趣报文进行重定向。 可以设置重定向的下一跳IP地址或出接口。
流策略:将流分类和流行为绑定,对分类后的报文执行对应流行为中定义的动作。一个流策略可以绑定多个流分类和流行为。
应用流策略:1.在接口入方向上应用流策略。 2.对属于该VLAN并匹配流分类中规则的入方向报文实施策略控制。3.在全局或板卡上应用流策略。
MQC的流行为支持重定向报文,因此可以使用MQC实现IP单播策略路由。
相关命令
创建匹配(流分类)规则ACL 3000,允许目的IP地址为3.3.3.3的数据流
[R1]acl 3000
[R1-acl-adv-3000]rule 5 permit ip destination 3.3.3.3 0创建流分类10(规则之间的关系为或),设置匹配(流分类)规则ACL 3000
[R1]traffic classifier 10 operator or
[R1-classifier-10]if-match acl 3000创建流行为10,设置行为为指定下一跳
[R1]traffic behavior 10
[R1-behavior-10]redirect ip-nexthop 10.1.2.2创建流策略11,并绑定流分类10与流行为10
[R1]traffic policy 11
[R1-trafficpolicy-11]classifier 10 behavior 10在接口的入方向应用流策略11
[R1-GigabitEthernet0/0/0]traffic-policy 11 inbound PBR MQC配置举例

R2 配置MQC
创建匹配(流分类)规则ACL 3000,匹配目的IP地址为1.1.1.1和10.1.1.1的数据流
[R2]acl 3000
[R2-acl-adv-3000]rule 5 permit ip destination 1.1.1.1 0
[R2-acl-adv-3000]rule 10 permit ip destination 10.1.1.1 0
创建流分类10(规则之间的关系为或),设置匹配(流分类)规则ACL 3000
[R2]traffic classifier 10 operator or
[R2-classifier-10]if-match acl 3000
创建流行为10,设置行为为指定下一跳
[R2]traffic behavior 10
[R2-behavior-10]redirect ip-nexthop 10.1.4.4
创建匹配(流分类)规则ACL 3001,匹配目的IP地址为3.3.3.3和10.1.3.3的数据流
[R2]acl 3001
[R2-acl-adv-3001]rule 5 permit ip destination 3.3.3.3 0
[R2-acl-adv-3001]rule 10 permit ip destination 10.1.3.3 0
创建流分类20(规则之间的关系为或),设置匹配(流分类)规则ACL 3001
[R2]traffic classifier 20 operator or
[R2-classifier-10]if-match acl 3001
创建流行为20,设置行为为指定下一跳
[R2]traffic behavior 20
[R2-behavior-10]redirect ip-nexthop 10.1.2.4
创建流策略11,并绑定流分类10与流行为10,绑定流分类20与流行为20
[R2]traffic policy 11
[R2-trafficpolicy-11]classifier 10 behavior 10
[R2-trafficpolicy-11]classifier 20 behavior 20
在接口的入方向应用流策略11
[R2-GigabitEthernet0/0/0]traffic-policy 11 inbound
[R2-GigabitEthernet0/0/1]traffic-policy 11 inboundR4 配置PBR
配置匹配规则ACL 3000,匹配R1的ip
[R4]acl 3000
[R4-acl-adv-3000]rule 5 permit ip destination 1.1.1.1 0
[R4-acl-adv-3000]rule 10 permit ip destination 10.1.1.1 0
创建PBR10 节点10
[R4]policy-based-route 10 permit node 10
设置匹配条件(匹配ACL 3000)
[R4-policy-based-route-10-10]if-match acl 3000
设置匹配动作(指定出接口g0/0/0)
[R4-policy-based-route-10-10]apply output-interface GigabitEthernet 0/0/0
配置匹配规则ACL 3001,匹配R3的ip
[R4]acl 3001
[R4-acl-adv-3001]rule 5 permit ip destination 3.3.3.3 0
[R4-acl-adv-3001]rule 10 permit ip destination 10.1.3.3 0
创建PBR10 节点20
[R4]policy-based-route 10 permit node 20
设置匹配条件(匹配ACL 3001)
[R4-policy-based-route-10-20]if-match acl 3001
设置匹配动作(指定出接口g0/0/1)
[R4-policy-based-route-10-20]apply output-interface GigabitEthernet 0/0/1
调用到全局(本地)PBR
[R4]ip local policy-based-route 10边栏推荐
- Chapitre 1: le roi de shehan a mal calculé
- The space of C disk is insufficient, and the computer becomes stuck. Quickly expand the capacity of C disk to make the system more smooth
- [free sharing] kotalog diary2022 plan electronic manual ledger
- Zhang Fei hardware 90 day learning notes - personal records on day 2, please see my personal profile / homepage for the complete
- Simulation scheduling problem of SystemVerilog (1)
- TFs and SVN [closed] - TFs vs SVN [closed]
- Random numbers in a long range, is that right- Random number in long range, is this the way?
- [water quality prediction] water quality prediction based on MATLAB Fuzzy Neural Network [including Matlab source code 1923]
- [disease identification] machine vision lung cancer detection system based on Matlab GUI [including Matlab source code 1922]
- Flume learning notes
猜你喜欢

Why should we do feature normalization / standardization?

Why should the gradient be manually cleared before back propagation in pytorch?
![[mathematical modeling] ship three degree of freedom MMG model based on MATLAB [including Matlab source code 1925]](/img/a9/d89ee2b88517eea6b3c38d72cf099f.jpg)
[mathematical modeling] ship three degree of freedom MMG model based on MATLAB [including Matlab source code 1925]

第二十章:y= sin(x)/x,漫步坐标系计算,y= sin(x)/x 带廓幅图形,奥运五环,小球滚动与弹跳,流水显示,矩形优化裁剪,r个皇后全控nxn棋盘

FBI警告:有人利用AI换脸冒充他人身份进行远程面试

Streaming media server (16) -- figure out the difference between live broadcast and on-demand

Yolov3 network model building

Chapter 1: King Shehan miscalculated

【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...

The necessity of lean production and management in sheet metal industry
随机推荐
Bad mentality leads to different results
Compared with 4G, what are the advantages of 5g to meet the technical requirements of industry 4.0
The earliest record
Luogu-p1107 [bjwc2008] Lei Tao's kitten
第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
Pecan — @expose()
Web Security (VIII) what is CSRF attack? Why can token prevent csdf attacks?
01 - QT OpenGL display OpenGL window
Chapter 1: recursively find the factorial n of n!
Octopus online ecological chain tour Atocha protocol received near grant worth $50000
Why should the gradient be manually cleared before back propagation in pytorch?
Find the median of two positive arrays
Free year-end report summary template Welfare Collection
QT -- qfile file read / write operation
FBI警告:有人利用AI换脸冒充他人身份进行远程面试
Pecan - route
Yolov3 network model building
EGO Planner代码解析bspline_optimizer部分(1)
QT -- qfileinfo file information reading
2020 intermediate financial management (escort class)