09 Preferred BGP Route Selection
09 Preferred BGP Route Selection
09 Preferred BGP Route Selection
Page 1 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Foreword
• The border gateway protocol (BGP) is a widely deployed routing protocol in the globe. BGP
defines multiple path attributes and has various routing policy tools, providing flexible route
control and path selection.
• Operations on BGP route attributes may affect route selection and therefore affect network
traffic. Therefore, it is important to master Rules for Selecting a Preferred BGP Route.
• This course illustrates Rules for Selecting a Preferred BGP Route.
Page 2 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Objectives
• Upon completion of this course, you will be able to:
▫ Describe rules for selecting a preferred BGP route.
Page 3 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Preferred BGP Route Selection
Page 4 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers. ↓ A smaller value indicates a
8. Prefers the route with the smallest IGP metric to the next hop. better route.
9. Prefers the route with the shortest Cluster_List length. If the preceding eight attributes are the same, routes
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID). work in load balancing mode.
11. Prefers the route learned from the peer with the smallest IP address.
Page 5 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Topology (1)
AS 200
R2 GE0/0/0 GE0/0/0 R1 GE0/0/1 GE0/0/0 R3
10.0.12.2/24 10.0.12.1/24 10.0.13.1/24 10.0.13.3/24
GE0/0/0 GE0/0/0
10.0.24.4/24 10.0.35.5/24
AS 100 R4 R5 AS 300
10.0.45.0/24
• The figure shows ASs and interconnection addresses. Loopback0 interfaces are created on all devices, and the IP address is 10.0.x.x
(x indicates the device ID). All devices use addresses of Loopback0 interfaces as router IDs.
• OSPF runs in AS 200 and OSPF is enabled on internal interconnection interfaces (excluding the interfaces connected to external AS)
and loopback interfaces.
Page 6 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Topology (2)
AS 200
R2 IBGP R1 IBGP R3
OSPF
EBGP EBGP
AS 100 R4 R5 AS 300
10.0.45.0/24
• Loopback0 interfaces are used for establishing IBGP peer relationships in ASs, and directly connected interfaces are used for
establishing EBGP peer relationships between ASs.
• R4 and R5 have the same network segment 10.0.45.0/24. The import-route command can be used to import the direct routes of this
network segment to BGP so as to verify BGP route selection.
Page 7 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 8 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Discarding the Route Whose Next Hop Is
Unreachable (1)
BGP Update
Total Number of Routes: 2 • When R4 and R5 advertise the BGP routes
Network NextHop MED LocPrf PrefVal Path/Ogn
10.0.45.0/24 to AS 200, the Next_Hop attribute values
i 10.0.45.0/24 10.0.24.4 0 100 0 100? of the routes are 10.0.24.4 and 10.0.34.5.
i 10.0.35.5 0 100 0 300?
• R2 and R3 do not modify the Next_Hop attribute
when advertising routes to R1. The next hops of the
AS 200 two BGP routes 10.0.45.0/24 learned by R1 are
10.0.24.4 and 10.0.34.5.
R2 R1 R3
• When R1 performs recursive query for next hops of
BGP routes, route recursion fails because OSPF is not
OSPF activated on the interfaces connecting R2 and R3 to
BGP Update BGP Update
external ASs. As a result, the next hop of the BGP
….. …..
Path Attribute: Path Attribute: route 10.0.45.0/24 on R1 is unreachable.
Nexthop 10.0.24.4 Nexthop 10.0.35.5
• Run the display bgp routing command on R1 to
AS 100 R4 R5 AS 300 check the BGP routing table. The command output
shows that the BGP route 10.0.45.0/24 is invalid.
10.0.45.0/24
Page 9 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Discarding the Route Whose Next Hop Is
Unreachable (2)
BGP Update
bgp 200
Peer 10.0.1.1 next-hop-local
10.0.45.0/24
Unless otherwise specified, devices in all subsequent cases use basic configuration. In addition to
the basic configuration, R2 and R3 are configured with peer next-hop-local.
Page 10 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Discarding the Route Whose Next Hop Is
Unreachable (3)
BGP Update Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
OSPF
BGP Update BGP Update
... ...
Path Attribute: Path Attribute:
Nexthop 10.0.2.2 Nexthop 10.0.3.3
AS 100 R4 R5 AS 300
10.0.45.0/24
Why is the BGP route with the next hop of 10.0.2.2 the optimal route when next hops of two BGP routes are reachable?
Page 11 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 12 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Changing the Preferred-Value Attribute
R1 sends data packets to 10.0.45.0/24. bgp 200
BGP Update
peer 10.0.3.3 preferred-value 100
Page 13 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Checking the BGP Routing Table of R1
The BGP route advertised by R3 at 10.0.3.3 has a higher Preferred-Value attribute value (100), so R1 prefers the BGP
route 10.0.45.0/24 advertised by R3.
Page 14 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 15 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Changing the Local_Preference Attribute (1)
BGP Update
Run the following commands on R3.
AS 200
R2 R1 R3 ip ip-prefix local_pref index 10 permit 10.0.45.0 24
#
route-policy local_pref permit node 10
OSPF
BGP Update BGP Update if-match ip-prefix local_pref
Configure a routing policy on R3 to change the Local_Preference value of the BGP route 10.0.45.0/24 advertised to R1.
Page 16 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Changing the Local_Preference Attribute (2)
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
BGP Update
Page 17 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized
route, route learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of
priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 18 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Locally Generated Route
• In the case of identical conditions, a locally generated route is preferred, and the route learned from a peer
has the secondary priority.
• In addition, locally generated routes may be learned in multiple ways. When the same route is learned in
multiple ways, the following routes are in descending order of priority:
▫ Summarized route by manually running the aggregate command in the BGP view
Page 19 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Manual Route Summarization (1)
R5 AS 300 • Configure two static routes on R3, import the static routes to
BGP using the import-route command, run the aggregate
10.0.45.0/24 command to manually summarize the routes, and specify
To manually summarize routes on R3, configure two static routes detail-suppressed suppress advertisement of specific routes.
pointing to null0 on R3 and import them to BGP.
Page 20 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Manual Route Summarization (2)
Page 21 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Manual Route Summarization (3)
Page 22 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Automatic Route Summarization (1)
• Run the following commands on R3.
bgp 200
OSPF summary automatic
import-route static
• Configure two static routes on R3, import the static routes to BGP using the
import-route command, and enable automatic summarization. BGP
R5 AS 300
summarizes routes by natural network segment. For example, class A
addresses 10.1.1.1/24 and 10.2.1.1/24 on the non-natural network segment are
10.0.45.0/24, 10.0.0.0/8 summarized into class A address 10.0.0.0/8 on the natural network segment. In
addition, BGP advertises only the summarized route to peers.
In this case, the configurations on R1, R3, and R5 are irrelevant to • On R3, you can view that the route is summarized to 10.0.0.0/8.
the configurations that have been performed in the example of
• R5 imports the route 10.0.0.0/8 and advertises it to R3.
manual summarization.
Page 23 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Automatic Route Summarization (2)
• The locally generated BGP route is preferred. However, there are two
10.0.45.0/24, 10.0.0.0/8
locally generated BGP routes, and the routing entry cannot help
determine whether the preferred route is manually or automatically
summarized.
Page 25 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Automatic Route Summarization (4)
BGP local router ID : 10.0.3.3 • Run the display bgp routing-table 10.0.0.0 command on R3 to
Local AS number : 200
check detailed information about the BGP route 10.0.0.0/8. The
Paths: 3 available, 1 best, 1 select
BGP routing table entry information of 10.0.0.0/8:
command output shows that there are three valid routes, among
Aggregated route. which the optimal route is generated by route summarization and
Route Duration: 00h08m17s has the Atomic-aggregate attribute. The command output shows
Direct Out-interface: NULL0
that the route is manually summarized.
Original nexthop: 127.0.0.1
Qos information : 0x0 • On R3, the manually summarized route is better than the
AS-path Nil, origin incomplete, pref-val 0, valid, local, best, select, active, automatically summarized route.
pre 255
Aggregator: AS 200, Aggregator ID 10.0.3.3, Atomic-aggregate • This example verifies that the manually summarized route is
Advertised to such 2 peers: better than the automatically summarized route.
10.0.35.5
10.0.1.1
Page 26 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 27 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Shortest AS_Path
(1)
BGP Update
AS 200
R2 R1 R3
C
OSPF
ip ip-prefix as_path index 10 permit 10.0.45.0 24 BGP Update BGP Update
... ...
#
Path Attribute: Path Attribute:
route-policy as_path permit node 10 AS_Path: 400 100 AS_Path: 300
Page 28 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Shortest AS_Path
(2)
OSPF
BGP Update BGP Update
... ...
Path Attribute: Path Attribute:
AS_Path: 400 100 AS_Path: 300
AS 100 R4 R5 AS 300
10.0.45.0/24
Page 29 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 30 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Origin Attribute Verification (1)
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
Page 31 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Origin Attribute Verification (2)
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
AS 200
R2 R1 R3
The Origin attribute of the BGP route
10.0.45.0/24 imported by R5 is “i”. If the
OSPF
BGP Update BGP Update preceding rules are the same, the BGP route
... ...
with the origin type being “i” becomes the
Path Attribute: Path Attribute:
Origin: ? Origin: i optimal route.
AS 100 R4 R5 AS 300
10.0.45.0/24
Page 32 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 33 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Smallest MED (1)
apply cost 20
route-policy med permit node 20 OSPF
# BGP Update BGP Update
... ...
bgp 200
Path Attribute: Path Attribute:
peer 10.0.1.1 route-policy med export MED: 20 No MED value
Page 34 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Smallest MED (2)
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
AS 200 carry the MED value (the default MED value is 0). The BGP route advertised by R5 has a smaller MED
value, and R1 preferentially selects the BGP route advertised by R5.
R2 R1 R3
OSPF
BGP Update BGP Update
… …
Path Attribute: Path Attribute:
MED: 20 No MED
AS 100 R4 R5 AS 300
10.0.45.0/24
Page 35 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 36 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring a Route Learned from an EBGP Peer
(1)
AS 200 10.0.45.0/24 • Run the following commands on R1.
OSPF #
route-policy ebgp permit node 10
if-match ip-prefix ebgp
apply as-path 500 additive
Page 37 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring a Route Learned from an EBGP Peer
(2)
AS 200 10.0.45.0/24
R1 R3
R5 and R1 are the EBGP peer and IBGP peer, respectively. The
R5 AS 300
BGP routes advertised by EBGP peers take precedence over the
BGP routes advertised by IBGP peers. R3 preferentially selects
10.0.45.0/24
the BGP routes advertised by R5.
Page 38 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring a Route Learned from an EBGP Peer
(3)
Page 39 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 40 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
IGP Cost
Page 41 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Smallest IGP Cost
(1)
BGP Update
AS 200
R2 R1 R3
OSPF
10.0.45.0/24
Page 42 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Smallest IGP Cost
(2)
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
R2 R1 R1 preferentially selectsR3
the BGP route with the next hop being 10.0.3.3.
OSPF
AS 100 R4 R5 AS 300
10.0.45.0/24
Page 43 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Smallest IGP Cost
(3)
Page 44 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Load Balancing Among BGP Routes
• On a large network, there may be multiple valid BGP routes to the same destination. The device will
select and add the optimal BGP route to its routing table for traffic forwarding.
• This, however, will result in uneven load balancing of much traffic. Configuring BGP load balancing can
enable the device to add these multiple equal-cost BGP routes to its routing table, implementing traffic
load balancing and reducing network congestion.
• After BGP load balancing is configured, the device will still select the optimal route among the multiple
routes and advertise only this route to its peers.
• After BGP load balancing is enabled on a device, only the BGP routes that meet specified conditions can
be used as equal-cost routes for load balancing.
Page 45 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Conditions for Load Balancing Among Equal-Cost
BGP Routes
• The Preferred-Value attribute values are the same.
Page 46 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Configuring BGP Load Balancing
bgp 200
maximum load-balancing ibgp 2
BGP Update
R4 R5
10.0.45.0/24 AS 45
Page 47 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Verifying the Configuration of Load Balancing
Among BGP Routes
[R1]display ip routing-table 10.0.45.0 24 The equal-cost routes to 10.0.45.0/24 exist in the IP routing table.
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.45.0/24 IBGP 255 0 RD 10.0.2.2 GigabitEthernet0/0/0
IBGP 255 0 RD 10.0.3.3 GigabitEthernet0/0/1
[R1]display bgp routing-table There is only one optimal route in the BGP routing table.
Page 48 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 49 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Shortest
Cluster_List Length (1)
• The following configuration is performed:
▫ Configure only R5 to advertise the route 10.0.45.0/24 to
IBGP
BGP.
AS 200
▫ Configure R1 as the RR and R3 as the client of R1.
R2 R1 R3
▫ Establish an IBGP peer relationship between R2 and R3
IBGP IBGP based on loopback interfaces.
RR Client
• R2 receives the BGP route 10.0.45.0/24 advertised by
R3 and the BGP route 10.0.45.0/24 reflected by R1.
Page 50 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Shortest
Cluster_List Length (2)
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
IBGP
Based on the BGP routing table, it cannot be determined
AS 200
whether the BGP route reflected by R1 or advertised by R3
R2 R1 R3
is preferred. To check detailed information about BGP
IBGP
RR
IBGP
Client
routes, run the display bgp routing 10.0.45.0 24
command.
10.0.45.0/24
Page 51 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Shortest
Cluster_List Length (3)
BGP routing table entry information of 10.0.45.0/24: • The route reflected by R1 is not the optimal route due to the
From: 10.0.1.1 (10.0.1.1)
following reason: not preferred for Cluster List
Route Duration: 00h03m10s
Relay IP Nexthop: 10.0.12.1 • The BGP route that R3 directly advertises to R2 does not pass
Relay IP Out-Interface: GigabitEthernet0/0/0 through the RR and therefore does not have the Cluster_List
Original nexthop: 10.0.3.3
attribute. That is, the Cluster_List attribute value of the BGP
Qos information : 0x0
AS-path 300, origin incomplete, MED 0, localpref 100, pref-val 0, valid, internal,
route advertised by R3 is considered as 0, which is smaller than
pre 255, IGP cost 2, not preferred for Cluster List the Cluster_List attribute value (1) of the BGP route reflected
Originator: 10.0.3.3 by R1. Therefore, the BGP route advertised by R3 is preferred.
Cluster list: 10.0.1.1
Not advertised to any peer yet
Page 52 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 53 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Smallest Router ID
(1)
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
AS 200
R2 R1 R3
OSPF
AS 100 R4 R5 AS 300
10.0.45.0/24
In the preceding topology, R1 receives BGP route 10.0.45.0/24 from both R2 and R3 by default, and the preceding route selection rules cannot determine
the optimal route. Therefore, R1 selects the BGP route advertised by the peer with the smallest router ID based on the preceding route selection rules. In
this example, the BGP route advertised by R2 is preferred.
Page 54 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Smallest Router ID
(2)
Page 55 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Smallest
Originator_ID (1)
Route update sent by BGP
RR
R1
OSPF 10.0.45.0/24
RR
R3 R5
If a BGP route carries the Originator_ID attribute, the router compares the Originator_ID values of the routes
and selects the BGP route with the smallest Originator_ID value.
Page 56 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route with the Smallest
Originator_ID (2)
Total Number of Routes: 2
BGP routing table entry information of 10.0.45.0/24:
Network NextHop MED LocPrf PrefVal Path/Ogn
From: 10.0.3.3 (10.0.3.3)
*>i 10.0.45.0/24 10.0.4.4 0 100 0 ?
Route Duration: 00h33m15s
*i 10.0.5.5 0 100 0 ?
Relay IP Nexthop: 10.0.13.3
R2 Relay IP Out-Interface: GigabitEthernet0/0/1
AS 100
Original nexthop: 10.0.5.5
R3
The BGP route reflected by R3 is not selected because of the
Route update sent by BGP
router ID. The router ID here refers to the Originator ID (router
Route update reflected by a BGP RR
ID of the original route advertiser).
Page 57 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Rules for Selecting a Preferred BGP Route
When multiple routes to the same destination network segment exist, BGP selects routes in the following sequence:
Discards the route whose next hop is unreachable.
3. Prefers the locally originated BGP route, which takes precedence over the route learned from a peer. The locally summarized route, automatically summarized route, route
learned by using the network command, route learned by using the import-route command, and route learned from a peer are in descending order of priority.
5. Prefers the route with the shortest AS_Path. The routes with Origin attributes of IGP, EGP, and Incomplete are in descending order of priority.
7. Prefers routes learned from EBGP peers to routes learned from IBGP peers.
8. Prefers the route with the smallest IGP metric to the next hop.
10. Prefers the route advertised by the device with the smallest router ID (Originator_ID).
11. Prefers the route learned from the peer with the smallest IP address.
Page 58 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route from the Device with the
Smallest IP Address (1)
Route update sent by BGP
RR
R1 R4
RR client
OSPF Router ID 10.0.45.0/24
10.0.4.4
RR
R3
• If the preceding rules cannot determine the optimal route, the route from the device with the smallest IP address is
preferred.
• In the preceding topology, R2 and R3 are connected to R4. R4 functions as the RR client and advertises routes to
BGP only on R4. In this case, the BGP routes reflected by R2 and R3 have the same Originator ID 10.0.4.4.
Page 59 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Preferring the Route from the Device with the
Smallest IP Address (2)
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn BGP routing table entry information of 10.0.45.0/24:
R3
The BGP route reflected by R3 is not selected because the peer address is
Route update sent by BGP larger. The peer address of the route reflected by R2 is 10.0.2.2, and the
Route update reflected by a BGP RR peer address of the route reflected by R3 is 10.0.3.3. Therefore, the BGP
route reflected by R3 is not selected.
Page 60 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Quiz
1. (Essay) When a BGP route received from an EBGP peer is advertised to an IBGP peer, how does the
EBGP peer change the value of the Next_Hop attribute to its own source address?
2. (TorF) If the preceding three rules are the same, BGP compares the AS_Path attribute values. If the
AS_Path attribute values are the same, BGP compares the AS numbers.
Page 61 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Summary
• BGP selects optimal routes based on path attributes. This allows BGP to select optimal routes
based on path attributes in different scenarios.
• BGP defines a set of detailed optimal path selection algorithms, which enable routers to select
the optimal path in any complex and highly redundant network environment.
• BGP route selection rules are frequently used in practice and need to be mastered.
Page 62 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
谢谢
Thank You
www.huawei.com
Page 63 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.