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 routes
01 优选Preferred-Value属性值最大的路由(华为设备特有属性)
修改属性方式:
1 使用preferred-value命令修改(在本机上修改,影响自身的路由优选)
[R7]b