首页 > 其他分享 >BGP路由优选(五)

BGP路由优选(五)

时间:2024-08-14 09:54:40浏览次数:8  
标签:优选 AR4 ip route BGP permit policy 路由

当到达同一个目的网段存在多条路由时,BGP通过如下的次序进行路由优选:

      丢弃下一跳不可达的路由。

  1. 优选Preferred-Value属性值最大的路由。
  2. 优选Local_Preference属性值最大的路由。
  3. 本地始发的BGP路由优于从其他对等体学习到的路由,本地始发的路由优先级:优选手动聚合>自动聚合>network>import>从对等体学到的。
  4. 优选AS_Path属性值最短的路由。
  5. 优选Origin属性最优的路由。Origin属性值按优先级从高到低的排列是:IGP、EGP及Incomplete。
  6. 优选MED属性值最小的路由。
  7. 优选从EBGP对等体学来的路由(EBGP路由优先级高于IBGP路由)。
  8. 优选到Next_Hop的IGP度量值最小的路由。
  9. 优选Cluster_List最短的路由。
  10. 优选Router ID(Orginator_ID)最小的设备通告的路由。
  11. 优选具有最小IP地址的对等体通告的路由。

当前8条属性全部相同时可以形成路由负载分担

BGP路由选路实验

IP规划、BGP对等体关系、AS号等信息如上图所示,按图中数据进行基本配置


需求1:R1去往4.4.4.4时,走R2并且保证任何情况下走R2,使用协议首选值实现

1. 配置命令

[AR1-bgp]peer 12.0.0.2 preferred-value 100

#将对等体12.0.0.2发送的所有路由的preferred-value值修改为10

2.验证


 需求2:将R3发给R1的9.9.9.9的协议首选值修改为50,使用route-policy实现

1.配置命令

[AR1]ip ip-prefix R3Pre permit 9.9.9.0 24

[AR1]route-policy R3Pre permit node 10
Info: New Sequence of this List.
[AR1-route-policy]if-match ip-prefix R3Pre 
[AR1-route-policy]apply preferred-value 50

[AR1-route-policy]route-policy R3Pre permit node 999
Info: New Sequence of this List.

[AR1-bgp]peer 13.0.0.3 route-policy R3Pre import

 2.验证


需求3:R4去1.1.1.1通过R3走,通过修改到达IBGP邻居地址的IGP度量值实现,并要求R4到达R1的Loopback 0接口的路由保持不变

1.配置命令

[AR4-GigabitEthernet0/0/2]ospf cost 2

[AR2-GigabitEthernet0/0/0]ospf cost 2

2.验证


需求4:在R1上通告192.168.1.0路由,将R4从R2学到此路由local pre修改为160,从R3学到到此路由的local pre修改为360,在R4上配置

1.配置命令

[AR4]ip ip-prefix R1Pre permit 192.168.1.0 24

[AR4]route-policy Pre160 permit node 10
Info: New Sequence of this List.
[AR4-route-policy]if-match ip-prefix R1Pre
[AR4-route-policy]apply local-preference 160
[AR4]route-policy Pre160 permit node 20
Info: New Sequence of this List.

[AR4]route-policy Pre360 permit node 10
Info: New Sequence of this List.
[AR4-route-policy]if-match ip-prefix R1Pre
[AR4-route-policy]apply local-preference 360
[AR4]route-policy Pre360 permit node 20

[AR4-bgp]peer 2.2.2.2 route-policy Pre160 import
[AR4-bgp]peer 3.3.3.3 route-policy Pre360 import

2.验证

3.注意事项

        当R4将192.168.1.0的本地优先级修改为360反射给R2后EBGP对等体R1获取到的192.168.1.0的本地优先级为100,没有R4反射过来的360优先级高,成为不活跃的路由,不进行传递。所以只出现下一跳3.3.3.3的路由,没有2.2.2.2的


需求5:在R3上将R1发来的1.1.1.0和192.168.1.0 的路由的起源属性修改为?,使R3去往这些网段走R2

1.配置命令

[AR3]ip ip-prefix changeOrg index 10 permit 1.1.1.0 24
[AR3]ip ip-prefix changeOrg index 20 permit 192.168.1.0 24

[AR3]route-policy changeOrg permit node 10
Info: New Sequence of this List.
[AR3-route-policy]if-match ip-prefix changeOrg
[AR3-route-policy]apply origin incomplete 
[AR3-route-policy]route-policy changeOrg permit node 20
Info: New Sequence of this List.

[AR3-bgp]peer 13.0.0.1 route-policy changeOrg import

2.验证

3.注意事项

        因为在需求4中将192.168.1.0的本地优先级在R4上修改为360,R2不反射192.168.1.0的路由,所以不受Origin属性的影响


需求6:在R5上通告5.5.5.0,在R6上通告6.6.6.0,要求R4访问6.6.6.0使用R5,访问5.5.5.0使用R6,在R6上配置,通过MED属性实现

1.代码配置

[AR4]ip ip-prefix R5 permit 5.5.5.0 24 
[AR4]ip ip-prefix R6 permit 6.6.6.0 24

[AR4]route-policy R5Med permit node 10
Info: New Sequence of this List.
[AR4-route-policy]if-match ip-prefix R5
[AR4-route-policy]apply cost 100
[AR4-route-policy]route-policy R5Med permit node 20
Info: New Sequence of this List.
[AR4-route-policy]if-match ip-prefix R6
[AR4-route-policy]apply cost 50
[AR4-route-policy]route-policy R5Med permit node 999
Info: New Sequence of this List.

[AR4-route-policy]route-policy R6Med permit node 10
Info: New Sequence of this List.
[AR4-route-policy]if-match ip-prefix R6
[AR4-route-policy]apply cost 100
[AR4-route-policy]route-policy R6Med permit node 20
Info: New Sequence of this List.
[AR4-route-policy]if-match ip-prefix R5
[AR4-route-policy]apply cost 50
[AR4-route-policy]route-policy R6Med permit node 999
Info: New Sequence of this List.

[AR4]bgp 100
[AR4-bgp]peer 45.0.0.5 route-policy R5Med import 
[AR4-bgp]peer 46.0.0.6 route-policy R6Med import

2.验证


需求7:R1访问5.5.5.5通过R2,访问6.6.6.6通过R3,使用AS-Pah属性实现,分别在R2和R3上实现

1.代码配置

[AR1]ip ip-prefix R5 permit 5.5.5.0 24 
[AR1]ip ip-prefix R6 permit 6.6.6.0 24

[AR1]route-policy AS-R2 permit node 10
Info: New Sequence of this List.
[AR1-route-policy]if-match ip-prefix R6
[AR1-route-policy]apply as-path 985 211 additive 
[AR1-route-policy]route-policy AS-R2 permit node 999
Info: New Sequence of this List.

[AR1-route-policy]route-policy AS-R3 permit node 999
Info: New Sequence of this List.
[AR1-route-policy]route-policy AS-R3 permit node  10
Info: New Sequence of this List.
[AR1-route-policy]if-match ip-prefix R5 
[AR1-route-policy]apply as-path 985 211 additive 

[AR1-route-policy]bgp 1
[AR1-bgp]peer 12.0.0.2 route-policy AS-R2 impor
[AR1-bgp]peer 13.0.0.3 route-policy AS-R3 import 

2.验证


9.踩坑点

 在配置R5和R6的IBGP邻居关系时,采用环回口建立邻居

1.坑点1:环回口配置的是32位掩码:如:5.5.5.5/32,在BGP中宣告5.5.5.0/24不成功

        原因:network的路由信息要与IP路由表中保持一致,没有或者不一致无法宣告

2.坑点2:环回口换成5.5.5.5/24后,宣告5.5.5.0/24成功,但是R4接收只接受到了R5宣告过来的路由,并未接收到R6宣告过来的路由

 1.现象

2.原因

         建立BGP邻居的路由跟bgp路由一样的话,传过去被认为不是最优路由,所以不会传递给其他对等体

标签:优选,AR4,ip,route,BGP,permit,policy,路由
From: https://blog.csdn.net/uzumcc/article/details/141139507

相关文章

  • [Zebra] 分片路由和寻找分片键值的基本过程
    路由规则匹配分库分表路由规则是表+字段的维度,首先要将sql中的表识别出来,然后和规则进行匹配,然后才能根据规则确定分库分表是用哪个字段、按照什么分片算法,比如userId8库128表;zebra中DefaultShardRouter#router路由器首先进行sql解析SQLParsedResultparsedResul......
  • flaskapi 路由管理APIRouter
    前言  开发一个应用程序或API,不会将所有的代码都放到main.py文件中。Flask使用蓝图(BluePrint)来管理路由,FastAPI提供了一个类似的工具APIRouter。路由管理1、fastapi项目目录层级 2、api/cms/user.py定义API路由和处理函数。实例化 APIRouter类,参数prefix......
  • HCIP笔记8-BGP(2)
    一、BGP的宣告问题1.在BGP协议中每台运行BGP的设备上,宣告本地直连路由2.*在BGP协议中运行BGP协议的设备还可以宣告通过IGP学习到的,未运行BGP协议设备产生的路由;在BGP协议中宣告本地路由表中路由条目时,将携带本地到达这些目标的IGP度量值;传递到BGP邻居处;其他AS设备便于选择离......
  • 使用 navigateTo 实现灵活的路由导航
    title:使用navigateTo实现灵活的路由导航date:2024/8/13updated:2024/8/13author:cmdragonexcerpt:摘要:本文详细介绍Nuxt.js中的navigateTo函数,包括基本用法、在路由中间件中使用、导航到外部URL和新标签页打开链接的方法,以及参数详解和注意事项,展示了该函数......
  • 网关路由-路由属性
    ♥️作者:小宋1021......
  • BGP反射器(四)
    解决IBGP全互联问题带来的问题:路由器需维护大量的TCP和BGP连接,尤其在路由器数量较多时AS内BGP网络的可扩展性较差角色RR:路由反射器Client:RR的客户端Non-Client:非客户机关系Client只与RR之间建立IBGP会话RR与RR之间建立IBGP全互联Non-Client与Non-Client之间建立IBGP全互联......
  • React Router 6 (React路由) 最详细教程
    ReactRouter6(React路由)最详细教程蒋川 2022-03-29阅读 5 分钟3 ReactRouter 经历多个版本的发展,现在已经到了 ReactRouter6。虽然网络上写React-Router路由本身的教程很多,但真正讲到React-Router6的并不多。同时因为第6版引......
  • 从零开发ts装饰器管理koa路由
    从零开发ts装饰器管理koa路由超人鸭关注IP属地:广东0.3252022.05.3118:18:44字数4,882阅读1,518前言两年前刚学ts,当时搭了个简单的koa的demo,介绍了如何用装饰器管理koa的路由:TS装饰器初体验,用装饰器管理koa接口但是当时还只是demo学习,并没有真正在公司的项目中使用......
  • BGP路径属性(三)
    BGP路径属性作用:用于选路和防环,任何一条BGP路由都拥有多个路径属性分类:公认:所有BGP路由器必须识别公认必遵:必须包括在每个Update消息中,如:Origin、AS_Path、Next_hop公认任意:可能包含在某些Update消息中,如:Local_preference、Atomic_aggregate可选:厂商实现自己私有特性......
  • 2.5.BGP-2
    多路访问网络next-hop实验:r2:ints0ipadd12.1.1.2255.255.255.0noshintlo0ipadd2.2.2.2255.255.255.0r1:ints0ipadd12.1.1.1255.255.255.0noshinte0ipadd134.1.1.1255.255.255.0noshintlo0ipadd1.1.1.1255.255.255.0noshr3:inte0ipa......