7.6 BGP路由优选规则

1.优选规则

1)优选Preferred_Value属性最大的路由。(华为私有属性,只在本地有效)

2)优选Local_Preferred属性最大的路由。

3)本地始发的BGP路由优于从其他对等体学习的路由。

4)优选AS_Path属性值最短的路由。

5)优选Origin属性值最短的路由。

6)优选MED属性值最小的路由。

7)优选从EBGP对等体学来的路由(EBGP路由优先级高于IBGP路由)。

8)优选Next_Hop的IGP度量值最小的路由。

9)优选Cluster_List最短的路由。

10)优选Router-ID最小的设备通过的路由。

11)优选具有最小IP地址的对等体通告的路由。

2.优选Preferred_Value属性最大的路由

图片[1]-7.6 BGP路由优选规则-大赛人网
图7-9 优选Preferred_Value属性最大的路由网络拓扑

1)基本配置

[R1]bgp 100
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.1.1.2 as-number 200
[R1-bgp]peer 13.1.1.3 as-number 300
[R1-bgp]network 1.1.1.1 32

[R2]bgp 200
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 12.1.1.1 as-number 100
[R2-bgp]peer 24.1.1.4 as-number 400

[R3]bgp 300
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 13.1.1.1 as-number 100
[R3-bgp]peer 34.1.1.4 as-number 400

[R4]bgp 400
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 24.1.1.2 as-number 200
[R4-bgp]peer 34.1.1.3 as-number 300

2)查看BGP路由表

[R4]display bgp routing-table 
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
*>   1.1.1.1/32         24.1.1.2                              0      200 100i
*                       34.1.1.3                              0      300 100i

[R4-bgp]display bgp routing-table 1.1.1.1
 AS-path 200 100, origin igp, pref-val 0, valid, external, best, select, active, pre 255
AS-path 300 100, origin igp, pref-val 0, valid, external, pre 255, not preferred for router ID

3)修改Preferred_Value属性

[R4-bgp]peer 34.1.1.3 preferred-value 6000
[R4]display bgp routing-table
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>   1.1.1.1/32         34.1.1.3                              6000   300 100i
 *                       24.1.1.2                              0      200 100i
[R4-bgp]display bgp routing-table 1.1.1.1 
Original nexthop: 34.1.1.3
 AS-path 300 100, origin igp, pref-val 6000, valid, external, best, select, active, pre 255
 Original nexthop: 24.1.1.2
 AS-path 200 100, origin igp, pref-val 0, valid, external, pre 255, not preferred for PreVal

3.优选Local_Preferred属性最大的路由

图片[2]-7.6 BGP路由优选规则-大赛人网
图7-10 优选Local_Preferred属性最大的路由网络拓扑

1)基本配置

[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 24.1.1.0 0.255.255.255
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0

[R3]ospf 1 router-id  3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 34.1.1.0 0.255.255.255
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0 

[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 24.1.1.0 0.255.255.255
[R4-ospf-1-area-0.0.0.0]network 34.1.1.0 0.255.255.255
[R4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0

2)配置BGP

[R1]bgp 100
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.1.1.2 as-number 234
[R1-bgp]peer 13.1.1.3 as-number 234
[R1-bgp]network 1.1.1.1 32

[R2]bgp 234
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 4.4.4.4 as-number 234
[R2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R2-bgp]peer 4.4.4.4 next-hop-local
[R2-bgp]peer 12.1.1.1 as-number 100

[R3]bgp 234
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 4.4.4.4 as-number 234
[R3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R3-bgp]peer 4.4.4.4 next-hop-local
[R3-bgp]peer 13.1.1.1 as-number 100

[R4]bgp 234
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 2.2.2.2 as-number 234  
[R4-bgp]peer 2.2.2.2 connect-interface LoopBack 0                    
[R4-bgp]peer 2.2.2.2 reflect-client 
[R4-bgp]peer 3.3.3.3 as-number 234 
[R4-bgp]peer 3.3.3.3 connect-interface LoopBack 0                 
[R4-bgp]peer 3.3.3.3 reflect-client

2)查看BGP路由表

[R4]display bgp routing-table 
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
*>i  1.1.1.1/32         2.2.2.2         0          100        0      100i
* i                     3.3.3.3         0          100        0      100i

3)修改Local_Preferred属性

[R3]ip ip-prefix 1 permit 1.1.1.1 32
[R3]route-policy dsrw.com permit node 10
[R3-route-policy]if-match ip-prefix 1
[R3-route-policy]apply local-preference 200
[R3]bgp 234
[R3-bgp]peer 4.4.4.4 route-policy dsrw.com export 

4)查看BGP路由表

<R4>display bgp routing-table
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
*>i  1.1.1.1/32         3.3.3.3         0          200        0      100i

4.本地始发的BGP路由优于从其他对等体学习的路由

图片[3]-7.6 BGP路由优选规则-大赛人网
图7-11 本地始发的BGP路由优于从其他对等体学习的路由网络拓扑

1)基本配置

[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 13.1.1.0 0.255.255.255
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0

[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 13.1.1.0 0.255.255.255
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0

2)配置BGP

[R1]bgp 13
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 3.3.3.3 as-number 13
[R1-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R1-bgp]peer 3.3.3.3 next-hop-local
[R1-bgp]peer 12.1.1.2 as-number 200

[R2]bgp 200
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 12.1.1.1 as-number 13
[R2-bgp]peer 23.1.1.3 as-number 13

[R3]bgp 13
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 1.1.1.1 as-number 13
[R3-bgp]peer 1.1.1.1 connect-interface  LoopBack 0
[R3-bgp]peer 1.1.1.1 next-hop-local
[R3-bgp]peer 23.1.1.2 as-number 200

3)R1、R3引入1.1.1.1/32,查看BGP路由(NextHop 为0.0.0.0路由被选中)

[R1-bgp]network 1.1.1.1 32
[R3-bgp]network 1.1.1.1 32
[R1-bgp]display bgp routing-table   
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>   1.1.1.1/32         0.0.0.0         0                     0      i
 * i                     3.3.3.3         1          100        0      i

[R3-bgp]display bgp routing-table  
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>   1.1.1.1/32         0.0.0.0         1                     0      i
   i                     1.1.1.1         0          100        0      i

优选AS_Path属性值最短的路由

图片[4]-7.6 BGP路由优选规则-大赛人网
图7-12 优选AS_Path属性值最短的路由网络拓扑

1)基本配置

[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 13.1.1.0 0.255.255.255
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0

[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 13.1.1.0 0.255.255.255
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0

2)配置BGP

[R1]bgp 13
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 3.3.3.3 as-number 13
[R1-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R1-bgp]peer 3.3.3.3 next-hop-local
[R1-bgp]peer 12.1.1.2 as-number 200

[R2]bgp 200
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 12.1.1.1 as-number 13
[R2-bgp]peer 23.1.1.3 as-number 13
[R2-bgp]network 2.2.2.2 32

[R3]bgp 13
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 1.1.1.1 as-number 13
[R3-bgp]peer 1.1.1.1 connect-interface  LoopBack 0
[R3-bgp]peer 1.1.1.1 next-hop-local
[R3-bgp]peer 23.1.1.2 as-number 200

[R1-bgp]display  bgp routing-table 
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>   2.2.2.2/32         12.1.1.2        0                     0      200i
 * i                     3.3.3.3         0          100        0      200i

3)修改AS_Path属性后查看BGP路由表

[R1-route-policy]display bgp routing-table
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
*>   2.2.2.2/32         12.1.1.2        0                     0      200i
 * i                     3.3.3.3         0          100        0      200i

[R2]ip ip-prefix 1 index 10 permit 2.2.2.2 32
[R2]route-policy dsrw.com permit node 10  
[R2-route-policy]if-match ip-prefix 1
[R2-route-policy]apply as-path 200 200 additive  

[R2]bgp 200
[R2-bgp]peer 12.1.1.1 route-policy dsrw.com export 

[R1-route-policy]display bgp routing-table 2.2.2.2
BGP local router ID : 12.1.1.1
 Local AS number : 13
 Paths:   2 available, 1 best, 1 select
 BGP routing table entry information of 2.2.2.2/32:
 From: 3.3.3.3 (3.3.3.3)
 Route Duration: 00h13m07s  
 Relay IP Nexthop: 13.1.1.3
 Relay IP Out-Interface: GigabitEthernet0/0/2
 Original nexthop: 3.3.3.3
 Qos information : 0x0
 AS-path 200, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 1
 Advertised to such 1 peers:
    12.1.1.2
 BGP routing table entry information of 2.2.2.2/32:
 From: 12.1.1.2 (2.2.2.2)
 Route Duration: 00h02m38s  
 Direct Out-interface: GigabitEthernet0/0/0
 Original nexthop: 12.1.1.2
 Qos information : 0x0
 AS-path 200 200 200, origin igp, MED 0, pref-val 0, valid, external, pre 255, not preferred for AS-Path
 Not advertised to any peer yet

[R1-route-policy]display bgp routing-table
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
*>i  2.2.2.2/32         3.3.3.3         0          100        0      200i
 *                       12.1.1.2        0                     0      200 200 200i

6.优选Origin属性值最短的路由

图片[5]-7.6 BGP路由优选规则-大赛人网
图7-13 优选Origin属性值最短的路由网络拓扑

1)基本配置

[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 13.1.1.0 0.255.255.255
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0

[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 13.1.1.0 0.255.255.255
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0

2)配置BGP

[R1]bgp 13
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 3.3.3.3 as-number 13
[R1-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R1-bgp]peer 3.3.3.3 next-hop-local
[R1-bgp]peer 12.1.1.2 as-number 200

[R2]bgp 200
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 12.1.1.1 as-number 13
[R2-bgp]peer 23.1.1.3 as-number 13
[R2-bgp]network 2.2.2.2 32

[R3]bgp 13
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 1.1.1.1 as-number 13
[R3-bgp]peer 1.1.1.1 connect-interface  LoopBack 0
[R3-bgp]peer 1.1.1.1 next-hop-local
[R3-bgp]peer 23.1.1.2 as-number 200

[R1-bgp]display  bgp routing-table 
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>   2.2.2.2/32         12.1.1.2        0                     0      200i
 * i                     3.3.3.3         0          100        0      200i

3)修改Origin属性后查看BGP路由表

[R2]ip ip-prefix 1 index 10 permit 2.2.2.2 32
[R2]route-policy dsrw.com permit node 10  
[R2-route-policy]if-match ip-prefix 1
[R2-route-policy]apply origin incomplete 
[R2]bgp 200
[R2-bgp]peer 12.1.1.1 route-policy dsrw.com export 

<R1>display bgp routing-table
Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>i  2.2.2.2/32         3.3.3.3         0          100        0      200i
 *                       12.1.1.2        0                     0      200?

<R1>display bgp routing-table 2.2.2.2
 BGP local router ID : 12.1.1.1
 Local AS number : 13
 Paths:   2 available, 1 best, 1 select
 BGP routing table entry information of 2.2.2.2/32:
 From: 3.3.3.3 (3.3.3.3)
 Route Duration: 00h41m38s  
 Relay IP Nexthop: 13.1.1.3
 Relay IP Out-Interface: GigabitEthernet0/0/2
 Original nexthop: 3.3.3.3
 Qos information : 0x0
 AS-path 200, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 1
 Advertised to such 1 peers:
    12.1.1.2
 BGP routing table entry information of 2.2.2.2/32:
 From: 12.1.1.2 (2.2.2.2)
 Route Duration: 00h00m55s  
 Direct Out-interface: GigabitEthernet0/0/0
 Original nexthop: 12.1.1.2
 Qos information : 0x0
 AS-path 200, origin incomplete, MED 0, pref-val 0, valid, external, pre 255, not preferred for Origin
 Not advertised to any peer yet

1 2

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称

    请登录后查看评论内容