13 route selection principles of BGP

 after the BGP router notifies the neighbor of the route, each BGP neighbor will carry out route optimization. There are three situations of route selection
① The route is the only route to the destination, which is directly optimized
② For multiple routes to the same destination, the highest priority is preferred
③ For multiple routes that arrive at the same destination and have the same priority, a more detailed principle must be used to select the optimal route
 in general, the rules for BGP to calculate route priority are as follows
① Discard the next unreachable route
② Preference_ Route with the highest value (private property, only valid locally)
③ Local priority_ Highest route
④ Prefer manual aggregation > automatic aggregation > Network > Import > learn from peers
⑤ Preferred AS_Path short route
⑥ IGP > EGP > incomplete
⑦ For routes from the same AS, it is better to select routes with small MED value
⑧ Optimizing routes learned from EBGP (EBGP > iBGP)
⑨ Select the Metric minimum route of IGP in AS
⑩ Preferred Cluster_List shortest route
⑪ Preferred originator_ Route with the smallest ID
⑫ Preferred router_ Route published by router with the smallest ID
⑬ Select the neighbor learned route with smaller IP address
















1. Preferred value

Preference_Value is the private attribute of BGP (Huawei private attribute), Preference_Value is equivalent to the Weight value in BGP routing rules, which only takes effect in the local router. Preference_ The larger the value is, the higher the priority is. The default value is 0. You can only change your own path selection

By default, Huawei will choose the router ID as its next best hop

<R1>display 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: 8
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
*>i  44.44.44.44/32     2.2.2.2         0          100        0      200i
  * i                     3.3.3.3         0          100        0      200i

① Match 44.44.44.44 entries - either acl or prefix list (recommended)

[R1]display ip ip-prefix 44
Prefix-list 44
Permitted 0
Denied 0
index: 10               permit  44.44.44.44/32
[R1]

② Create routing policy

#
Route policy 44 permit node 10 -- this is the way we need to associate
 If match IP prefix 44 -- this is our condition
 Apply preferred value 200 --- this is our action
#

③ Call under BGP view

[R1 BGP] peer 3.3.3.3 route policy 44 import can only be called in the in direction

④ Verification (the phenomenon is that the route R1 arrives at 44.44.44.44 points to R3 next)

[R1]display 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: 7
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

*>i  44.44.44.44/32     3.3.3.3         0          100        200    200i
  * i                     2.2.2.2         0          100        0      200i
[R1]

Summary: pre value maximum, preference_ The higher the value, the higher the priority. The default value is 0

2. Local_Preference

Local_ The pref attribute is only valid between IBGP neighbors and is not advertised to other AS. It indicates the BGP priority of the router, which is used to determine the best route when the traffic leaves AS. It is generally used to control how the traffic in my area goes out. By default, the local pref value is 100. The higher the value is, the higher the priority is

① Match 44.44.44.44 entries - either acl or prefix list (recommended)

[R3]display ip ip-prefix 44
Prefix-list 44
Permitted 0
Denied 0
index: 10               permit  44.44.44.44/32
[R1]

② Create routing policy

#
Route policy 44 permit node 10 -- this is the way we need to associate
 If match IP prefix 44 -- this is our condition
 Apply local preference 200 -- this is our action
#

③ Call under BGP view

[R3-bgp]peer 1.1.1.1 route-policy 44 export

When it is called in BGP, it can be called in our three directions
 first direction: call on the G0/0/0 interface of R3, but only in the import direction of G0/0/0
 the second direction: call in the G0/0/1 interface of R3, but only in the export direction of G0/0/1
 the third direction: call at the G0/0/1 interface of R1, but only in the import direction of G0/0/1
 cannot be called in the export direction of R4 (because local preference can only be passed in this AS)



3. Route aggregation

 priority of aggregation route: manual aggregation > automatic aggregation
 automatic aggregation
Only BGP routes with import route can be aggregated. If the BGP route is through import route, its attribute is "import route"?
 manual polymerization
Manual aggregation can be performed on the routes in the BGP routing table. If it is announced to our BGP through our network, its attribute is i (it can take effect on both the incoming route and the network announced route)
 if the BGP route table contains both the introduced route and the network announced route, it can only be realized by manual aggregation
 verify that manual aggregation is greater than automatic aggregation
The route entry of 44.44.44.44 on R4 is declared by the network. At this time, the automatic aggregation cannot be recognized. I can modify the origin attribute of our 44 network segment on R4. Through our prefix list and router-policy, R2 can automatically aggregate the route of 44.44.44.44 by applying it to one of the outgoing directions of R4 In R3, manual aggregation is enabled (manual aggregation can aggregate routes announced by network and routes announced by route). Because R1 receives entries from R2 for automatic aggregation and R3 for manual aggregation, the next hop from R1 to this aggregation route is R3








Automatic aggregation

① By default, BGP does not enable automatic aggregation
② Automatic aggregation is only effective for incoming routes, not for network routes
③ After automatic aggregation is configured, member detail routing will be suppressed
④ It is found that the details are preceded by an S (supplied)
⑤ What other routers learn is auto converged routing

① Create loopback interface on R1 device, match the loopback interface of R1 with prefix list, and introduce it into BGP protocol





[R1]display ip ip-prefix 1
Prefix-list 1
Permitted 3
Denied 10
        index: 10               permit  100.100.2.0/24          
        index: 20               permit  100.100.3.0/24          
        index: 30               permit  100.100.4.0/24  

② Create routing policy

[R1]display route-policy 1
Route-policy : 1
  permit : 10 (matched counts: 16)
    Match clauses : 
      if-match ip-prefix 1

③ Call under BGP view

#
bgp 100
import-route direct route-policy 1
  summary automatic    Enable our automatic aggregation (note that it must be aggregation of the introduced routes, network Incoming routes are not valid)
# 
return

④ Check the experimental phenomenon at R1

[R1]display 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: 9
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

  *>   100.0.0.0          127.0.0.1                             0      ?
  s>   100.100.2.0/24     0.0.0.0         0                     0      ?
  s>   100.100.3.0/24     0.0.0.0         0                     0      ?
  s>   100.100.4.0/24     0.0.0.0         0                     0      ?
 [R1]

So the route learned by R2 is our aggregated route

<R2>display bgp routing-table 

 BGP Local router ID is 2.2.2.2 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete
 Total Number of Routes: 5
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

*>i  100.0.0.0          1.1.1.1                    100        0      ?
<R2>

Manual aggregation

Remove the command of automatic aggregation in the automatic manual aggregation route of R1 device


① detail-suppressed
Note: the later detail suppressed parameter is to suppress the details. If it is not added, both the detailed route and the aggregate route will be passed



[R1-bgp]aggregate 100.100.0.0 16 detail-suppressed

② as-set
AS set information is important in avoiding routing loops, because it records the AS that the aggregated route passes through

[R1-bgp]aggregate 100.100.0.0 16 as-set 

③ Suppress-policy
The keyword suppress policy can generate aggregate routes, but suppress the advertisement of specified routes. You can use the route policy and if match clauses to selectively suppress some specific routes. Other specific routes are still advertised (inhibit some routes in the aggregation)
④ Origin-policy
Use the keyword origin policy to only select the specific path matching the route policy to generate an aggregate route (as long as I have this route information, I can generate an aggregate route)


Problems caused by route aggregation

If the AS information of all detailed routes is carried after route aggregation, the aggregation route may also be affected by frequent updates when the detailed routes are subject to frequent shocks. Therefore, whether the aggregation route carries the lost AS_Path information requires comprehensive consideration of network environment by designers

4.Network is greater than import

When publishing the route of 4.4.4.4 to RT2, change the attribute to incomplete (that is, the way of introduction) to see the path selection of RT1 to 4.4.4.4
By default, R1 will select the route with smaller router id according to the 13 route selection principles. Let's keep the first three route selection principles unchanged. i can change the fourth route selection principle, because by default, 44.44.44/32 of R4 is published to our BGP through network, and its default origin attribute is network (that is, our i) i can change the origin attribute of R2 to R1, which becomes the route learned through import

1. Match the entry of 44.44.44.44 - the method is acl or prefix list (recommended)


[R2]display ip ip-prefix 44
Prefix-list 44
Permitted 2
Denied 1
        index: 10               permit  44.44.44.44/32   

2. Create routing policy

[R2]display  route-policy
Route-policy : 44
  permit : 10 (matched counts: 1)
    Match clauses : 
      if-match ip-prefix 44
    Apply clauses : 
      apply origin incomplete 

3. Call under BGP view

#
bgp 100
 router-id 2.2.2.2
 peer 1.1.1.1 as-number 100 
 peer 1.1.1.1 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  peer 1.1.1.1 enable
  peer 1.1.1.1 route-policy 44 export
#
return
[R2-bgp]

 note:
① You can call the export direction (G0/0/0) of R2
② You can call in the import direction of R2 (G0/0/1)
③ It can be called in the import direction of R1 (G0/0/0)
④ It can be called in the export direction of R4 (G0/0/1)



5.AS_Path

 receive the shortest AS path priority in the same route
When RTA receives a route of 100.0.0.0/24 from RTB, AS_ When the path is (2, 4) and RTA receives a route of 100.0.0.0/24 from RTC, AS_Path is (3, 5, 4). Regulation AS_ The shorter the path (the fewer AS numbers recorded), the better the path, so the RTA will prefer the route of 100.0.0.0/24 received from the RTB
 AS path properties prevent BGP loops
Taking RTE AS an example, BGP issues 100.0.0.0/24 routes, which may form a loop through RTE - > RTB - > RTC - > RTD - > RTE. In order to prevent loop generation, RTE will check AS when receiving the route from RTD_ Path property, if the AS of the route is found_ If the path contains its own AS number, the route will be discarded

 by default, R1 will select the route with smaller router id according to the 13 route selection principles. Let's keep the first four route selection principles unchanged and change the fifth route selection principle. When R2 sends the route to the 44.44.44.44 network segment of R1, I can add some AS-path attributes, which can be added in the following two ways
① Add: Append to original As Number add as path attribute on the original basis
② Overwrite: Overwrite original As Number overwrites the as path attribute to directly erase the original as path








  1. Match 44.44.44.44 entries - either acl or prefix list (recommended)
    [R2]display ip ip-prefix 44
    Prefix-list 44
    Permitted 4
    Denied 2
        index: 10               permit  44.44.44.44/32    

    2. create routing policy

    [R2]display route-policy 44
    Route-policy : 44
    permit : 10 (matched counts: 2)
    Match clauses : 
      if-match ip-prefix 44
    Apply clauses : 
      apply as-path 1000 2000 3000 additive

    3. Call under BGP view

    #
    bgp 100
    router-id 2.2.2.2
    peer 1.1.1.1 as-number 100 
    peer 1.1.1.1 connect-interface LoopBack0
    peer 3.3.3.3 as-number 100 
    peer 3.3.3.3 connect-interface LoopBack0
    peer 24.1.1.4 as-number 200 
    #
    ipv4-family unicast
    undo synchronization
    network 22.22.22.22 255.255.255.255 
    peer 1.1.1.1 enable
    peer 1.1.1.1 route-policy 44 export
    peer 1.1.1.1 next-hop-local 
    peer 3.3.3.3 enable
    peer 3.3.3.3 next-hop-local 
    peer 24.1.1.4 enable
    #
    return
    [R2-bgp]

     note:
    ① You can call the export direction (G0/0/0) of R2
    ② You can call in the import direction of R2 (G0/0/1)
    ③ It can be called in the import direction of R1 (G0/0/0)
    ④ It can be called in the export direction of R4 (G0/0/1)



    6.Origin

     the Origin attribute defines the source of path information and marks how a route becomes a BGP route
     three attributes of Origin
    ① i indicates that BGP route is injected through network command
    ② E indicates that BGP routing is learned from EGP, and EGP protocol is difficult to see in the current network, but the Origin attribute of routing can be changed to e through routing strategy
    ③ ? that is, Incomplete indicates that BGP routes learn route information through other ways, such as routes introduced by using the import command
     the priority of the three Origin attributes is: I > e > incomplete (?) So the route announced by network is larger than that introduced by import router






    7.MED

    The MED (multi exit discriminator) attribute is only passed between two adjacent AS's, and the AS receiving this attribute will not notify any other third party AS, which is used to determine the best route when traffic enters AS
    When a router running BGP obtains multiple routes with the same destination address but different next hop through different EBGP neighbors, under the same other conditions, the router with the smaller MED value is preferred as the best route, and its default value is 0. The smaller MED value is the best route, and its default value is 0


  2. Match 44.44.44.44 entries - either acl or prefix list (recommended)
    [R2]display ip ip-prefix 44
    Prefix-list 44
    Permitted 5
    Denied 2
        index: 10               permit  44.44.44.44/32     

    2. Create routing policy

    [R2]display  route-policy 44
    Route-policy : 44
    permit : 10 (matched counts: 3)
    Match clauses : 
      if-match ip-prefix 44
    Apply clauses : 
      apply cost 1000 
    #

    3. Call under BGP view

    bgp 100
    router-id 2.2.2.2
    peer 1.1.1.1 as-number 100 
    peer 1.1.1.1 connect-interface LoopBack0
    peer 3.3.3.3 as-number 100 
    peer 3.3.3.3 connect-interface LoopBack0
    peer 24.1.1.4 as-number 200 
    #
    ipv4-family unicast
    undo synchronization
    network 22.22.22.22 255.255.255.255 
    peer 1.1.1.1 enable
    peer 1.1.1.1 next-hop-local 
    peer 3.3.3.3 enable
    peer 3.3.3.3 next-hop-local 
    peer 24.1.1.4 enable
    peer 24.1.1.4 route-policy 44 import
    #
    return
    [R2-bgp]

     note:
    ① You can call the export direction in R2 (G0/0/0)
    ② You can call in the import direction of R2 (G0/0/1)
    ③ It can be called in the import direction of R1 (G0/0/0)
    ④ It can be called in the export direction of R4 (G0/0/1)



    8.EBGP is better than IBGP route

    According to the routing principle, RTA will select the routes learned from EBGP neighbors

    Because R2 can receive the routing entry of ebgp from R4 or R3 (because R2 and R3 establish the BGP relationship of IBGP). If the previous 7 routing principles are the same, then we will compare our 8 selection principles, so the route from R2 to 44 should be delivered by ebgp



[R2]display bgp routing-table 

 BGP Local router ID is 2.2.2.2 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 6
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

  *>   44.44.44.44/32     24.1.1.4        0                     0      200i
    * i                     3.3.3.3         0          100        0      200i
 [R2]

9. Overhead value of IGP

By adjusting OSPF Cost, RTA selects R3 path to access 44.44.44.44/32

Change ospf cost of G0/0/0 interface of R1 to 2

#
interface GigabitEthernet0/0/0
 ip address 12.1.1.1 255.255.255.0 
#
return
[R1-GigabitEthernet0/0/0]ospf cost 2
[R1]display ip routing-table 44.44.44.44
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

    44.44.44.44/32  IBGP    255  0          RD   3.3.3.3         GigabitEthernet
0/0/1

View BGP routing table of R1

[R1]display 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: 6
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

*>i  44.44.44.44/32     3.3.3.3         0          100        0      200i
  * i                     2.2.2.2         0          100        0      200i

[R1]

10. Router ID value

By default, if all the previous routing principles are the same, a route with a smaller router ID will be selected as its own routing method

<R1>display 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: 6
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

*>i  44.44.44.44/32     2.2.2.2         0          100        0      200i
  * i                     3.3.3.3         0          100        0      200i
<R1>

Tags: network Attribute

Posted on Wed, 20 May 2020 03:21:55 -0700 by promovi