菱形组网之BGP MED、负载分担及GR篇

 

 

BGP选路规则

1.     MEDRouterID<)和负载分担

到达同一目的地的多条路由,选择最优路由,下发到IP路由表

PE1查看路由表

[PE1]dis ip routing-table                                                      

Route Flags: R - relay, D - download to fib                                    

------------------------------------------------------------------------------ 

Routing Tables: Public                                                         

         Destinations : 22       Routes : 22                                   

                                                                                

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface     

                                                          

4.4.4.4/32        EBGP    255   0        D   100.1.3.2     GigabitEthernet0/2/2 

可以

可以看到PE4loopback0路由选择的是PE3为下一跳

继续查看详细原因

[PE1]dis bgp routing-table 4.4.4.4 32                                           

                                                                               

 BGP local router ID : 1.1.1.1                                                 

 Local AS number : 200                                                          

 Paths:   2 available, 1 best, 1 select                                        

 BGP routing table entry information of 4.4.4.4/32:                            

 From: 100.1.3.2 (3.3.3.3)                                                      

 Route Duration: 00h19m35s                                                     

 Direct Out-interface: GigabitEthernet0/2/2                                    

 Original nexthop: 100.1.3.2                                                   

 Qos information : 0x0                                                         

 AS-path 100, origin incomplete, pref-val 0, valid, external, best, select, acti

ve, pre 255                                                                    

 Advertised to such 2 peers:                                                   

    100.1.3.2                                                                  

    100.1.2.2                                                                  

 BGP routing table entry information of 4.4.4.4/32:                            

 From: 100.1.2.2 (2.2.2.2)                                                     

 Route Duration: 00h17m34s                                                     

 Direct Out-interface: GigabitEthernet0/2/5                                    

 Original nexthop: 100.1.2.2                                                   

 Qos information : 0x0                                                         

 AS-path 100, origin incomplete, MED 1, pref-val 0, valid, external, pre 255, no

t preferred for MED                                                             

 Not advertised to any peer yet  

 

MEDMulti-exit Discriminator),多出口辨别符,主要就是给来自AS外的两个目的IP相同,下一跳不同的路由选择用,本例中,PE2PE3都给了PE1 4.4.4.4路由,但是为啥没有选择PE3的?可以看看PE1BGP路由表,选择MED值小的。

[PE1]dis bgp routing-table                                                     

                                                                                

 BGP Local router ID is 1.1.1.1                                                

 Status codes: * - valid, > - best, d - damped,                                

               h - history,  i - internal, s - suppressed, S - Stale           

               Origin : i - IGP, e - EGP, ? - incomplete                       

                                                                               

                                                                                

 Total Number of Routes: 12                                                    

      Network            NextHop        MED    LocPrf    PrefVal Path/Ogn  

     

 *>   4.4.4.4/32         100.1.3.2                            0      100?     

 *                      100.1.2.2       1                   0      100?

 

路由器ID

    PE2上发布100.2.3.0路由

    PE1上看到

[PE1]dis bgp routing-table 100.2.3.0                                           

                                                                                

 BGP local router ID : 1.1.1.1                                                 

 Local AS number : 200                                                         

 Paths:   2 available, 1 best, 1 select                                        

 BGP routing table entry information of 100.2.3.0/24:                          

 From: 100.1.2.2 (2.2.2.2)                                                     

 Route Duration: 00h06m07s                                                     

 Direct Out-interface: GigabitEthernet0/2/5                                    

 Original nexthop: 100.1.2.2                                                   

 Qos information : 0x0                                                         

 AS-path 100, origin igp, MED 0, pref-val 0, valid, external, best, select, acti

ve, pre 255                                                                    

 Advertised to such 2 peers:                                                   

    100.1.3.2                                                                   

    100.1.2.2                                                                  

 BGP routing table entry information of 100.2.3.0/24:                          

 From: 100.1.3.2 (3.3.3.3)                                                      

 Route Duration: 00h02m05s                                                     

 Direct Out-interface: GigabitEthernet0/2/2                                    

 Original nexthop: 100.1.3.2                                                    

 Qos information : 0x0                                                         

 AS-path 100, origin igp, MED 0, pref-val 0, valid, external, pre 255, not prefe

rred for router ID                                                              

 Not advertised to any peer yet   

    11条,路由器ID小的被选中。

    看红色字体部分,选中了一条路由,如果想要选中两条路由做负载分担,可以在PE1配置

maximum load-balancing ebgp 2

 

[PE1]dis bgp routing-table 100.2.3.0                                           

                                                                               

 BGP local router ID : 1.1.1.1                                                 

 Local AS number : 200                                                         

 Paths:   2 available, 1 best, 2 select

 

如果想让PE3的被选中

可以在PE3bgp进程里应用路由策略,路由策略

route-policy med permit node 10                                                

 apply cost 99   (该值是MED值)

peer 100.1.3.1 route-policy med export  

reset BGP进程

然后在PE1上看效果

BGP routing table entry information of 100.2.3.0/24:                          

 From: 100.1.3.2 (3.3.3.3)                                                     

 Route Duration: 00h00m23s                                                      

 Direct Out-interface: GigabitEthernet0/2/2                                    

 Original nexthop: 100.1.3.2                                                   

 Qos information : 0x0                                                         

 AS-path 100, origin igp, MED 99, pref-val 0, valid, external, pre 255, not pref

erred for MED                                                                  

 Not advertised to any peer yet 

 

2.       BGP GR

没使能GR之前,在PE2 reset bgp进程

  --- 100.2.3.1 ping statistics ---                                            

    143 packet(s) transmitted                                                  

    127 packet(s) received                                                      

    11.18% packet loss                                                         

round-trip min/avg/max = 1/1/1 ms  

PE1上会出现丢包

前面OSPFv3已经说过,此处不再重复。一个restarter一个helper