当前位置:网站首页>2022-07-19 网工进阶(二十)BGP-路由优选、路由优选逐条分析
2022-07-19 网工进阶(二十)BGP-路由优选、路由优选逐条分析
2022-07-27 18:03:00 【鹅一只】
BGP路由优选
当到达同一个目的网段存在多条路由时,BGP通过如下的次序进行路由优选
01 优选Preferred-Value属性值最大的路由。
02 优选Local_Preference属性值最大的路由。
03 本地始发的BGP路由优于从其他对等体学习到的路由,本地始发的路由优先级:优选手动聚合>自动聚合>network>import>从对等体学到的。
04 优选AS_Path属性值最短的路由。
05 优选Origin属性最优的路由。Origin属性值按优先级从高到低的排列是:IGP、EGP及Incomplete。
06 优选MED属性值最小的路由。
07 优选从EBGP对等体学来的路由(EBGP路由优先级高于IBGP路由)。
08 优选到Next_Hop的IGP度量值最小的路由。
09 优选Cluster_List最短的路由。
10 优选Router ID(Orginator_ID)最小的设备通告的路由。
11 优选具有最小IP地址的对等体通告的路由。
上述规则依序排列,BGP进行路由优选时,从第一条规则开始执行,如果根据第一条规则无法作出判断,例如路由的Preferred-Value属性值相同,则继续执行下一条规则,如果根据当前的规则,BGP能够决策出最优的路由,则不再继续往下执行。类似于ACL匹配规则。
BGP路由优选逐条分析
实验拓扑

查看BGP详细路由,可查看未被优选的原因
<R7>display bgp routing-table 11.11.11.11
BGP local router ID : 7.7.7.7
Local AS number : 200
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 11.11.11.11/32:
From: 5.5.5.5 (5.5.5.5)
Route Duration: 00h06m10s
Relay IP Nexthop: 20.2.0.5
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 5.5.5.5
Qos information : 0x0
AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, bes
t, select, active, pre 255, IGP cost 1
Not advertised to any peer yet
BGP routing table entry information of 11.11.11.11/32:
From: 6.6.6.6 (6.6.6.6)
Route Duration: 00h06m25s
Relay IP Nexthop: 20.3.0.6
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 6.6.6.6
Qos information : 0x0
AS-path 100, origin igp, localpref 100, pref-val 0, valid, internal, pre 255, I
GP cost 1, not preferred for router ID
Not advertised to any peer yet分析:其中,第二条路由最下面注明了“not preferred for router ID”,说明这条路由未被优选的原因是Router ID比较大。
多条BGP路由负载均衡(影响本机)
[R7-bgp]maximum load-balancing ibgp ?
INTEGER<1-8> Specify maximum equal cost routes01 优选Preferred-Value属性值最大的路由(华为设备特有属性)
修改属性方式:
1 使用preferred-value命令修改(在本机上修改,影响自身的路由优选)
[R7]bgp 200
[R7-bgp]peer 6.6.6.6 preferred-value 100查看修改后的结果
<R7>display bgp routing-table
BGP Local router ID is 7.7.7.7
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 11
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 11.11.11.11/32 6.6.6.6 100 100 100i
* i 5.5.5.5 0 100 0 100i
*>i 22.22.22.22/32 6.6.6.6 0 100 100 100i
* i 5.5.5.5 100 0 100i
*>i 33.33.33.33/32 6.6.6.6 100 100 100i
* i 5.5.5.5 100 0 100i
*>i 44.44.44.44/32 6.6.6.6 100 100 100i
* i 5.5.5.5 100 0 100i
*>i 55.55.55.55/32 5.5.5.5 0 100 0 i
*>i 66.66.66.66/32 6.6.6.6 0 100 100 i
*> 77.77.77.77/32 0.0.0.0 0 0 i
分析:PrefVal字段大的路由,被优选。修改preferred-value的特性是所有下一跳为6.6.6.6的路由都被优选,属于对全局进行修改。
2 使用路由策略修改(在本机上修改,影响自身的路由优选)
[R7]acl 2000
[R7-acl-basic-2000]rule 5 permit source 11.11.11.11 0
[R7]route-policy 1 permit node 10
[R7-route-policy]if-match acl 2000
[R7-route-policy]apply preferred-value 200
[R7]bgp 200
[R7-bgp]peer 5.5.5.5 route-policy 1 import 查看修改后的结果
<R7>display bgp routing-table
BGP Local router ID is 7.7.7.7
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 7
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 11.11.11.11/32 5.5.5.5 0 100 200 100i
* i 6.6.6.6 100 100 100i
*>i 22.22.22.22/32 6.6.6.6 0 100 100 100i
*>i 33.33.33.33/32 6.6.6.6 100 100 100i
*>i 44.44.44.44/32 6.6.6.6 100 100 100i
*>i 66.66.66.66/32 6.6.6.6 0 100 100 i
*> 77.77.77.77/32 0.0.0.0 0 0 i分析:采用策略路由的方式进行修改,可修改某条指定的路由条目,相对于第1中方法,更加的精准。
02 优选Local_Preference属性值最大的路由。
本地优先级属性会在AS内部传递,不会传递给其他AS。缺省值100。
修改属性方式:
1 修改默认本地优先级(在AS内的边界路由上器修改,影响AS内部的其他路由器)
[R5]bgp 200
[R5-bgp]default local-preference 200
[R6]bgp 200
[R6-bgp]default local-preference 200查看修改后的结果
<R7>dis bgp routing-table
BGP Local router ID is 7.7.7.7
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 11
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 11.11.11.11/32 5.5.5.5 0 200 0 100i
* i 6.6.6.6 200 0 100i
*>i 22.22.22.22/32 5.5.5.5 200 0 100i
* i 6.6.6.6 0 200 0 100i
*>i 33.33.33.33/32 5.5.5.5 200 0 100i
* i 6.6.6.6 200 0 100i
*>i 44.44.44.44/32 5.5.5.5 200 0 100i
* i 6.6.6.6 200 0 100i
*>i 55.55.55.55/32 5.5.5.5 0 200 0 i
*>i 66.66.66.66/32 6.6.6.6 0 200 0 i
*> 77.77.77.77/32 0.0.0.0 0 0 i分析:所有LocPrf字段值都变为200,属于对全局进行修改。
2 使用路由策略修改(在AS内的边界路由上器修改,影响AS内部的其他路由器)
[R5]acl 2000
[R5-acl-basic-2000]rule 5 permit source 11.11.11.11 0
[R5]route-policy 1 permit node 10
[R5-route-policy]if-match acl 2000
[R5-route-policy]apply local-preference 300
[R5]route-policy 1 permit node 20
[R5]bgp 200
[R5-bgp]peer 1.1.1.1 route-policy 1 import查看修改结果
<R7>display bgp routing-table
BGP Local router ID is 7.7.7.7
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 10
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 11.11.11.11/32 5.5.5.5 0 300 0 100i
*>i 22.22.22.22/32 5.5.5.5 200 0 100i
* i 6.6.6.6 0 200 0 100i
*>i 33.33.33.33/32 5.5.5.5 200 0 100i
* i 6.6.6.6 200 0 100i
*>i 44.44.44.44/32 5.5.5.5 200 0 100i
* i 6.6.6.6 200 0 100i
*>i 55.55.55.55/32 5.5.5.5 0 200 0 i
*>i 66.66.66.66/32 6.6.6.6 0 200 0 i
*> 77.77.77.77/32 0.0.0.0 0 0 i分析:采用策略路由的方式进行修改,可修改某条指定的路由条目,相对于第1中方法,更加的精准。
03 本地始发的BGP路由优于从其他对等体学习到的路由,本地始发的路由优先级:优选手动聚合>自动聚合>network>import>从对等体学到的
04 优选AS_Path属性值最短的路由
详见
2022-07-15 网工进阶(十九)BGP-状态机、对等体之间的交互原则、影响对等体关系建立的因素、对等体表、路由表、详细路由表、路由属性_鹅一只的博客-CSDN博客
05 优选Origin属性最优的路由。Origin属性值按优先级从高到低的排列是:IGP、EGP及Incomplete
详见
2022-07-15 网工进阶(十九)BGP-状态机、对等体之间的交互原则、影响对等体关系建立的因素、对等体表、路由表、详细路由表、路由属性_鹅一只的博客-CSDN博客
06 优选MED属性值最小的路由
MED(Multi-Exit Discriminator,多出口鉴别器)是可选非过渡属性,是一种度量值,用于向外部对等体指出进入本AS的首选路径,即当进入本AS的入口有多个时,AS可以使用MED动态地影响其他AS选择进入的路径。
MED属性值越小则BGP路由越优。
MED主要用于在AS之间影响BGP的选路。MED被传递给EBGP对等体后,对等体在其AS内传递路由时,携带该MED值,但将路由再次传递给其EBGP对等体时,缺省不会携带MED属性。
特性:
MED最多只影响相邻的两个AS,收到MED属性的AS不会再把它传递给其他AS。
MED属性类似COST,适用在当一个目的地有多个路由情况下,和一个AS有多个入口的情况下,可手动配置MED进行路由的优选。
使用路由策略修改(在AS内的边界路由上器修改,影响AS内其他路由器-export,影响自身-import)
[R5]acl 2000
[R5-acl-basic-2000]rule 5 permit source 11.11.11.11 0
[R5]route-policy 1 permit node 10
[R5-route-policy]if-match acl 2000
[R5-route-policy]apply cost 20
[R5]bgp 200
[R5-bgp]peer 1.1.1.1 route-policy 1 import
[R5-bgp]compare-different-as-med
[R5-bgp]bestroute med-none-as-maximum
PS:
compare-different-as-med命令。缺省情况下,路由器只比较来自同一相邻AS的BGP路由的MED值,可以通过该命令开启来自不同AS的相同路由也比较MED值。
bestroute med-none-as-maximum命令。配置BGP在选择最优路由时,如果路由属性中没有MED值则按最大值处理。
查看修改结果
[R5]display bgp routing-table
BGP Local router ID is 5.5.5.5
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 11
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 11.11.11.11/32 1.1.1.1 100 0 100i
* i 6.6.6.6 100 0 100i
*>i 22.22.22.22/32 6.6.6.6 0 100 0 100i
* 1.1.1.1 0 100i
*> 33.33.33.33/32 1.1.1.1 0 100i
* i 6.6.6.6 100 0 100i
*> 44.44.44.44/32 1.1.1.1 0 100i
* i 6.6.6.6 100 0 100i
*> 55.55.55.55/32 0.0.0.0 0 0 i
*>i 66.66.66.66/32 6.6.6.6 0 100 0 i
*>i 77.77.77.77/32 7.7.7.7 0 100 0 i分析:去往11.11.11.11的路由因为下一跳1.1.1.1的路由MED值改为了100,但是因为配置了bestroute med-none-as-maximum命令,因此去往11.11.11.11和22.22.22.22的路由中,MED在丢失的情况下的路由为最大值,都不被优选。
07 优选从EBGP对等体学来的路由(EBGP路由优先级高于IBGP路由)
假如到达一个目的地有2条不同的路由,一条从IBGP学习到,一条从EBGP学习到,会优选EBGP学习到的这条。
08 优选到Next_Hop的IGP度量值最小的路由
指底层IGP协议的开销值,例如OSPF、IS-IS
修改方式详见
2022-04-09 网工进阶(三)OSPF-度量值、三大表项、邻居_鹅一只的博客-CSDN博客
2022-06-27 网工进阶(十二)IS-IS-开销类型、开销计算、LSP的处理机制、路由撤销、路由渗透_鹅一只的博客-CSDN博客_路由开销计算
09 优选Cluster_List最短的路由
相关命令
配置反射器
[R7-bgp]peer 6.6.6.6 reflect-client 10 优选Router ID(Orginator_ID)最小的设备通告的路由
11 优选具有最小IP地址的对等体通告的路由
指更新源地址大小
边栏推荐
- 我也是醉了,Eureka 延迟注册还有这个坑
- MySQL log error log
- Introduction to zepto
- Why do we need third-party payment?
- Common ways to keep requests idempotent
- Interviewer: what is the abstract factory model?
- MySQL log query log
- MediaTek releases Helio g80, a mid-range game phone chip
- Ten year test old bird talk about mobile terminal compatibility test
- Assignment 1 - Hello World ! - Simple thread Creation
猜你喜欢

Oracle Xe installation and user operation

站在巨人肩膀上学习,京东爆款架构师成长手册首发

Oracle +JDBC

access control

Two years after its release, the price increased by $100, and the reverse growth of meta Quest 2

Scrollintoview realizes simple anchor location (example: select city list)

OA项目之我的审批(查询&会议签字)

【阿里安全 × ICDM 2022】20万奖金池!大规模电商图上的风险商品检测赛火热报名中!...

My approval of OA project (Query & meeting signature)

PyQt5快速开发与实战 4.3 QLabel and 4.4 文本框类控件
随机推荐
【效率】弃用 Notepad++,这款开源替代品更牛逼!
How bad can a programmer be?
Common methods of object learning [clone and equals]
Pyqt5 rapid development and practice 4.5 button controls and 4.6 qcombobox (drop-down list box)
软件测试面试题:已知一个数字为1,如何输出“0001
面了个腾讯拿38K跳槽出来的,见识到了真正的测试天花板
C语言--数组
shell
A recently summarized universal violent cracking method
[Alibaba security × ICDM 2022] 200000 bonus pool! The risk commodity inspection competition on the large-scale e-commerce map is in hot registration
MLX90640 红外热成像仪测温传感器模块开发笔记(七)
[map set]
如何监控NVIDIA Jetson的的运行状态和使用情况
IM即时通讯开发如何提升移动网络下图片传输速度和成功率
Standing on the shoulders of giants to learn, jd.com's popular architect growth manual was launched
一个程序员的水平能差到什么程度?
多点双向重发布及路由策略的简单应用
发布2年后涨价100美元,Meta Quest 2的逆生长
Adjust the array so that odd numbers all precede even numbers
Huiding Technology: the acquisition of NXP vas business has been completed