22.BGP+Basics+-+Route+Selection+Rules

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 53

Course Objectives

After completing this course, you will be able to:


•Understand BGP route selection rules.
•Master the method of deploying routing policies based on route selection rules.
Technical Background

• When a BGP device learns multiple BGP routes (paths) t


o the same destination network, the device adds these r
AS 64512 AS 64513 outes to the BGP routing table, selects the optimal route,
and adds only the optimal route to the IP routing table for
data forwarding.
R1 R2 • When multiple routes exist, BGP advertises only the opti
mal route to its peers.
• BGP has a series of route selection rules. During route
BGP route advertisement BGP route advertisement selection, a router compares route attributes in
AS_Path AS_Path
MED MED descending order of the rules. If the optimal route is
Origin Origin selected using the current rule, the router does not go to
... ...
the next rule.
R3
• BGP route selection rules are closely related to BGP
path attributes and routing policies, contributing to BGP’s
powerful routing control capabilities.
Example of a BGP Routing Table

[R4] display bgp routing-table


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

Total Number of Routes: 4


Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 100.0.1.0/24 3.3.3.3 0 100 10 100i
*i 5.5.5.5 0 100 0 200i

The preceding BGP routing table contains two BGP routes to the network 100.0.1.0/24. Of the two routes, the device sel
ects the optimal route, marks it with a right angle bracket (>), and adds it to the IP routing table.
All routes in the BGP routing table are valid and marked with an asterisk (*) at the beginning. Valid routes are those
whose Next_Hop is reachable (the device has a route to the Next_Hop in the IP routing table). Invalid BGP routes
cannot be selected.
Overview of BGP Route Selection Rules
BGP selects the optimal route as follows:

1. Prefers the route with the largest Preferred_Value. 7. Prefers the route advertised by an EBGP peer.

2. Prefers the route with the largest Local_Preference. 8. Prefers the route with the smallest IGP cost to the Next_Hop.

3. Prefers locally originated routes. 9. Allows multiple routes to participate in load balancing (if

4. Prefers the route with the shortest AS_Path. configured).

5. Prefers the route with the highest Origin priority 10. Prefers the route with the shortest Cluster_List.

(IGP>EGP>Incomplete). 11. Prefers the route sent by the BGP peer with the smallest

6. Prefers the route with the smallest MED. router ID.

12. Prefers the route sent by the peer with the lowest IP

address.
BGP route selection rules may vary with vendors. These BGP route selection rules are implemented by Huawei devices
running a V8 version.
Topology for Verifying Route Selection Rules

AS 100 AS 200

R1 R2
GE 0/0/0 GE 0/0/0
10.1.13.1/24 10.1.25.2/24

GE 0/0/0 GE 0/0/1
10.1.13.3/24 10.1.25.5/24
GE 0/0/1 GE 0/0/1
10.1.34.3/24 10.1.45.4/24
GE 0/0/0 GE 0/0/0
10.1.34.4/24 10.1.45.5/24
R3 R4 R5
OSPF
AS 345

• IP addresses and ASs are planned according to the topology. Interface loopback 0 is configured on all routers, and its
IP address is in the format of x.x.x.x/32, where x is the device ID.
• In AS 345, OSPF is enabled on involved interfaces (including loopback 0) of R3, R4, and R5.
• EBGP peer relationships are established using directly connected interfaces. IBGP peer relationships are established
using loopback 0 interfaces.
Topology for Verifying Route Selection Rules

AS 100 AS 200

R1 R2

EBGP peer

EBGP peer
IBGP peer IBGP peer
R3 R4 R5

AS 345
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load Balancing

3. Preferring Locally Originated Routes (If Configured)

4. Preferring the Route with the Shortest AS_Path 10. Preferring the Route with the Shortest Cluster_List

5. Preferring the Route with the Highest Origin 11. Preferring the Route Sent by the BGP Peer with the

Priority (IGP>EGP>Incomplete) Smallest Router ID

6. Preferring the Route with the Smallest MED 12. Preferring the Route Sent by the Peer with the Lowest IP

Address
Preferred_Value

• Preferred_Value is a Huawei proprietary path attribute and is similar to a priority. Its value is
an integer ranging from 0 to 65535. The larger the value, the higher the priority.

• This attribute is valid only locally and is not sent to any peers.

• The default Preferred_Values of locally originated routes and the routes received from BGP
peers are both 0.
Modifying the Preferred_Value of All Routes Received from a Specified Peer

100.0.1.0/24 100.0.1.0/24

R1 R2

AS 100 AS 200

100.0.1.0/24 100.0.1.0/24

R3 R5

AS 345 R4 5.5.5.5

[R4] bgp 345


[R4-bgp] peer 5.5.5.5 preferred-value 10
/ /After this command is run, R4 sets the Preferred_Value of all
BGP routes received from R5 to 10. In this way, R4 prefers the
route 100.0.1.0/24 received from R5. BGP route
Using a Route-policy to modify the Preferred_Value

100.0.1.0/24 100.0.1.0/24 Key configurations of R4 are as follows:


100.0.2.0/24 100.0.2.0/24
ip ip-prefix 1 permit 100.0.1.0 24
R1 R2 ip ip-prefix 2 permit 100.0.2.0 24

AS 100 AS 200 route-policy RP1 permit node 10


if-match ip-prefix 1
100.0.1.0/24 100.0.1.0/24 apply preferred-value 10
100.0.2.0/24 100.0.2.0/24 route-policy RP1 permit node 20

R3 R5 route-policy RP2 permit node 10


if-match ip-prefix 2
AS 345 3.3.3.3 R4 5.5.5.5 apply preferred-value 10
route-policy RP2 permit node 20
BGP route
bgp 345
peer 3.3.3.3 route-policy RP1 import
Route-policies are configured on R4 so that it preferentially selects th peer 5.5.5.5 route-policy RP2 import
e route 100.0.1.0/24 advertised by R3 and the route 100.0.2.0/24 adv
ertised by R5.
Using a Route-policy to Modify the Preferred_Value

[R4]display bgp routing-table


BGP Local router ID is 4.4.4.4 R4 preferentially selects the route 100.0.1.0/
Status codes: * - valid, > - best, d - damped, 24 advertised by R3.

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


R4 preferentially selects the route 100.0.2.0/
Origin : i - IGP, e - EGP, ? - incomplete
24 advertised by R5.
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 100.0.1.0/24 3.3.3.3 0 100 10 100i
*i 5.5.5.5 0 100 0 200i
*>i 100.0.2.0/24 5.5.5.5 0 100 10 200i
*i 3.3.3.3 0 100 0 100i
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load Balancing (If

3. Preferring Locally Originated Routes Configured)

4. Preferring the Route with the Shortest 10. Preferring the Route with the Shortest Cluster_List

AS_Path 11. Preferring the Route Sent by the BGP Peer with the Smallest

5. Preferring the Route with the Highest Origin Router ID

Priority (IGP>EGP>Incomplete) 12. Preferring the Route Sent by the Peer with the Lowest IP

6. Preferring the Route with the Smallest MED Address


Using a Route-policy to Modify the Local_Preference

100.0.1.0/24 100.0.1.0/24

Key configurations of R3 are as follows:


R1 R2
ip ip-prefix 1 permit 100.0.1.0 24
AS 100 AS 200
route-policy RP permit node 10
100.0.1.0/24 100.0.1.0/24 if-match ip-prefix 1
LP=200 LP=100 apply local-preference 200
route-policy RP permit node 20
R3 R5
bgp 345
R4
AS 345 peer 4.4.4.4 route-policy RP export
4.4.4.4

BGP route

A route-policy is configured on R3 to set the Local_Preference of the route 100.0.1.0/24 to 200 when R3 advertises the
route to R4 so that R4 preferentially selects the route 100.0.1.0/24 advertised by R3.
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load Balancing

3. Preferring Locally Originated Routes (If Configured)

4. Preferring the Route with the Shortest AS_Path 10. Preferring the Route with the Shortest Cluster_List

5. Preferring the Route with the Highest Origin 11. Preferring the Route Sent by the BGP Peer with the

Priority (IGP>EGP>Incomplete) Smallest Router ID

6. Preferring the Route with the Smallest MED 12. Preferring the Route Sent by the Peer with the Lowest IP

Address
Rule Description

• If other conditions are the same, locally originated routes take precedence over routes learned from peers.

• Locally originated routes include routes imported using the network or import-route command, manual summary r
outes, and automatic summary routes. Locally originated routes are selected as follows:

1. Summary routes take precedence over non-summary routes.

2. Manual summary routes generated using the aggregate command take precedence over the automatic
summary routes generated using the summary automatic command.

3. The routes imported using the network command take precedence over the routes imported using the import-
route command.
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load Balancing (If

3. Preferring Locally Originated Routes Configured)

4. Preferring the Route with the Shortest AS_Path 10. Preferring the Route with the Shortest Cluster_List

5. Preferring the Route with the Highest Origin 11. Preferring the Route Sent by the BGP Peer with the

Priority (IGP>EGP>Incomplete) Smallest Router ID

6. Preferring the Route with the Smallest MED 12. Preferring the Route Sent by the Peer with the Lowest IP

Address
Using a Route-policy to Modify the AS_Path Attribute

100.0.1.0/24 100.0.1.0/24
Key configurations of R3 are as follows:

R1 AS 100 AS 200 R2 ip ip-prefix 1 permit 100.0.1.0 24


100.0.1.0/24
10.1.13.1 route-policy RP permit node 10
AS_Path=100
if-match ip-prefix 1
100.0.1.0/24 100.0.1.0/24 apply as-path 100 additive
AS_Path=100 100 AS_Path=200 route-policy RP permit node 20

R3 R5 bgp 345
peer 10.1.13.1 route-policy RP import
AS 345 R4

BGP route

An import policy is created on R3 to configure R3 to add an AS number (100) to the AS_Path attribute of the route 100.0.1.0/24
advertised by R1 after receiving the route. In this way, the length of the AS_Path attribute is increased by 1 after R4 receives
the route. Therefore, R4 prefers the route advertised by R5.
Using a Route-policy to Modify the AS_Path Attribute

• The following commands can be used to modify the AS_Path of BGP routes:
• apply as-path xxx additive Adds xxx to the existing AS_Path.
• apply as-path xxx overwrite Replaces the existing AS_Path value with xxx.
• apply as-path none overwrite Clears the AS_Path.

• A route-policy can be used to modify the AS_Path of EBGP routes. On Huawei routers, you can also u
se a route-policy to modify the AS_Path of IBGP routes. Exercise caution when modifying the AS_Pat
h of BGP routes because the modification may lead to routing loops.

• The bestroute as-path-ignore command configures BGP to ignore AS_Path length comparison when
selecting the optimal route. By default, the route with the shortest AS_Path length is preferred.
Supplement 1 to the AS_Path-based Route Selection Rule

• Rule supplement: No matter how many AS numbers an AS_Set contains, BGP regards the AS_Set as one AS
number when calculating routes.

R1
172.16.1.0/24

AS 100 In this example, R6 considers that the


AS_Set {100,200} contains only one AS
R2 R4 172.16.0.0/16
number when selecting the optimal
AS_PATH: 400 {100,200}
172.16.2.0/24 route. In this case, the AS_Path lengths
Summa r y

R6 of the two routes to 172.16.0.0/16 are


AS 200 AS400
the same. Therefore, R6 needs to
compare other attributes to select the
R3 R5 AS 600 optimal route.
172.16.3.0/24 Summa r y 172.16.0.0/16
AS_PATH: 500 300
AS 300 AS500
Supplement 1 to the AS_Path-based Route Selection Rule

• Rule supplement: No matter how many AS numbers an AS_Set contains, BGP regards the AS_Set as one AS
number when calculating routes.
In this example, R7 considers that the AS_Set
{999,100,200} contains only one AS number when
R1 R4
selecting the optimal route. In this case, the AS_Path
172.16.1.0/24
lengths of the two routes to 172.16.0.0/16 are the same.
AS 100 AS 999 Therefore, R7 needs to compare other attributes to
select the optimal route.
R2 R5 S
u 172.16.0.0/16
172.16.2.0/24 m AS_Path: 400 {999,100,200}
m
a R7
AS200 AS 400
r
y

R3 R6
S AS 600
u
172.16.3.0/24 m 172.16.0.0/16
m AS_Path: 500 300
a
AS 300 AS500
r
y
Supplement 2 to the AS_Path-based Route Selection Rule

• Rule supplement: AS_CONFED_SEQUENCE and AS_CONFED_SET are not involved in AS_Path length calculati
on.

AS 200 R2
R5 prefers the route 10.1.1.0/24 learned
from R4 because its AS_Path is shorter
than the AS_Path of the route learned from
R3.
R1 R3
10.1.1.0/24

AS 100 AS 300

10.1.1.0/24
Confederation AS 45 AS_Path=300 200 100
R4 R5
AS_Path length: 3

AS 64514 AS 64515
10.1.1.0/24
AS_Path=(64514) 100
AS_Path length: 1
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load Balancing (If

3. Preferring Locally Originated Routes Configured)

4. Preferring the Route with the Shortest 10. Preferring the Route with the Shortest Cluster_List

AS_Path 11. Preferring the Route Sent by the BGP Peer with the

5. Preferring the Route with the Highest Origin Smallest Router ID

Priority (IGP>EGP>Incomplete) 12. Preferring the Route Sent by the Peer with the Lowest IP

6. Preferring the Route with the Smallest MED Address


Origin

• Origin is also a well-known mandatory attribute. It indicates how a route becomes a BGP route. According to the way
a route became a BGP route, Origin is classified into three types: IGP, EGP, and Incomplete.
• When multiple routes to the same destination have different Origin attributes and other conditions are the same, BGP
selects routes according to the following sequence of Origin types: IGP > EGP > Incomplete.

Name Mark Description


Indicates that the route was added to the BGP routing table using the network
IGP i command. Such routes must exist in the routing table.

EGP e Indicates that the route was learned through EGP.

Indicates that the origin of the route cannot be identified. For example, if a route
Incomplete ?
was imported using the import-route command, its Origin is Incomplete.
Using a Route-policy to Modify the Origin Attribute

100.0.1.0/24 100.0.1.0/24
Key configurations of R1 are as follows:
ip ip-prefix 1 permit 100.0.1.0 24
R1 R2
route-policy RP permit node 10
AS 100 AS 200 if-match ip-prefix 1
apply origin incomplete
100.0.1.0/24 100.0.1.0/24 route-policy RP permit node 20
Origin=? Origin=i
10.1.13.3 bgp 100
R3 R5 network 100.0.1.0 24
peer 10.1.13.3 as-number 345
R4 peer 10.1.13.3 route-policy RP export
AS 345
BGP route

R1 and R2 import the route 100.0.1.0/24 to BGP using the network command. A route-policy is created on R1 to configure R1
to change the Origin attribute of the route 100.0.1.0/24 to Incomplete before advertising the route to R3. In this case, R4 prefers
the route 100.0.1.0/24 advertised by R5.
Using a Route-policy to Modify the Origin Attribute

[R4]display bgp routing-table


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

Total Number of Routes: 2


Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 100.0.1.0/24 5.5.5.5 0 100 0 200 i


*i 3.3.3.3 0 100 0 100 ?
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load

3. Preferring Locally Originated Routes Balancing (If Configured)

4. Preferring the Route with the Shortest 10. Preferring the Route with the Shortest Cluster_List

AS_Path 11. Preferring the Route Sent by the BGP Peer with the

5. Preferring the Route with the Highest Origin Smallest Router ID

Priority (IGP>EGP>Incomplete) 12. Preferring the Route Sent by the Peer with the Lowest

6. Preferring the Route with the Smallest MED IP Address


Preferring the Route with the Smallest MED

• Multi-exit discrimination (MED) is an optional non-transitive attribute used to determine the optimal route when traffic enters
an AS with multiple ASBRs.
• During route selection, the route with the smallest MED value is selected as the optimal route if all other attributes are the
same.
• After the MED is sent to an EBGP peer, the peer keeps the MED in the route when transmitting the route within its AS. Once
the route leaves the AS, the MED is not transmitted to the next AS.

Route-policies are configured on A and B so that the MED

1.1.1.0/24 value of the BGP route 1.1.1.0/24 advertised by A to C is 1


A B
0, and the MED value of the 1.1.1.0/24 route advertised by
AS 100
B is 20. If other conditions are the same, C preferentially s
BGP route 9 1.1.1.0/2 BGP route 5 1.1.1.0/2
MED = 10 MED = 20 elects the BGP route advertised by A.

AS 200 BGP route 1.1.1.0/2 4 AS 300


C D
By default, the MED is not carried.
Impact of MED on BGP Route Selection

• By default, a router compares the MED values of only the BGP routes that are destined for the same
destination and are received from the same neighboring AS. If two routes are destined for the same
destination but are received from different neighboring ASs, the router does not compare the MED
values. To enable the router to compare the MED values in such cases, run the compare-different-as-
med command.

• If a route does not carry MED, BGP considers its MED as the default value (0) during route selection. If
the bestroute med-none-as-maximum command is run, BGP considers its MED as the largest MED
value (4294967295).
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load Balancing

3. Preferring Locally Originated Routes (If Configured)

4. Preferring the Route with the Shortest AS_Path 10. Preferring the Route with the Shortest Cluster_List

5. Preferring the Route with the Highest Origin 11. Preferring the Route Sent by the BGP Peer with the

Priority (IGP>EGP>Incomplete) Smallest Router ID

6. Preferring the Route with the Smallest MED 12. Preferring the Route Sent by the Peer with the Lowest

IP Address
Preferring the Route Advertised by an EBGP Peer

100.0.1.0/24 100.0.1.0/24

R1 R2
R5 learns the BGP route 100.0.1.0/24 from IBGP
AS 100 AS 200 peer R3 and EBGP peer R2. When other conditions
are the same, R5 prefers the BGP route learned from
100.0.1.0/24 100.0.1.0/24
R2.
10.1.13.3
R3 R5

AS 345 R4

BGP route 100.0.1.0/24

Note: In this topology, an IBGP peer relationship is established between R3 and R5 using loopback 0 interfaces. The
peer next-hop-local command is run on R3, with R5 specified as the peer.
Preferring the Route Advertised by an EBGP Peer

[R5-bgp]display bgp routing-table 100.0.1.0


BGP routing table entry information of 100.0.1.0/24:
From: 10.1.25.2 (2.2.2.2)
Original nexthop: 10.1.25.2
AS-path 200, origin igp, MED 0, pref-val 0, valid, external, best, select, active, pre 255
...
BGP routing table entry information of 100.0.1.0/24:
From: 3.3.3.3 (10.1.13.3)
Route Duration: 00h01m22s
Original nexthop: 3.3.3.3
AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre255, IGP cost 2, not preferred for peer type

Describes the reason why the route is not selected.


Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to

2. Preferring the Route with the Largest the Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load

3. Preferring Locally Originated Routes Balancing (If Configured)

4. Preferring the Route with the Shortest 10. Preferring the Route with the Shortest Cluster_List

AS_Path 11. Preferring the Route Sent by the BGP Peer with the

5. Preferring the Route with the Highest Origin Smallest Router ID

Priority (IGP>EGP>Incomplete) 12. Preferring the Route Sent by the Peer with the

6. Preferring the Route with the Smallest MED Lowest IP Address


Preferring the Route with the Smallest IGP Cost to the Next_Hop

100.0.1.0/24 100.0.1.0/24 • An IBGP peer relationship is established between R3


and R4, and between R4 and R5, and their loopback
R1 R2 interfaces are configured as update sources. OSPF
runs in AS 345 so that each router can learn routes to
AS 100 AS 200
loopback interfaces of other routers.
100.0.1.0/24 100.0.1.0/24
• R4 learns the BGP route 100.0.1.0/24 from R3 and
NH=3.3.3.3 NH=5.5.5.5
10.1.13.3 R5, with the Next_Hops of 3.3.3.3 and 5.5.5.5,
R3 R5 respectively. When other conditions are the same, R4
R4
compares the costs of the routes to the two
AS 345 OSPF Cost=10 OSPF Cost=1
Next_Hops. Because the route learned from R5 has a
BGP route smaller cost to its Next_Hop, R4 prefers the route
learned from R5.
Preferring the Route with the Smallest IGP Cost to the Next_Hop

100.0.1.0/24 100.0.1.0/24 • An IBGP peer relationship is established between R3 and


R4, between R4 and R5, and between R3 and R5. Their
R1 R2 loopback interfaces are configured as update sources.
OSPF runs in AS 345 so that each router can learn routes
AS 100 AS 200
to loopback interfaces of other routers.
100.0.1.0/24 • R4 is configured as an RR, with R3 as its client.
NH=3.3.3.3
• When R5 learns the BGP route 100.0.1.0/24 from R3 and
R3 R5
R4, how does R5 select the optimal route? Which route
selection rule takes effect?

100.0.1.0/24 • The eighth rule does not take effect because the Next_Ho
BGP route
NH=3.3.3.3 AS 345 p attribute values of the two BGP routes are the same (3.3.
R4 (RR)
3.3).

• The tenth rule that is to preferentially select the route with t


he shortest Cluster_List. Therefore, the route learned from
R3 is preferred.
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load

3. Preferring Locally Originated Routes Balancing (If Configured)

4. Preferring the Route with the Shortest 10. Preferring the Route with the Shortest Cluster_List

AS_Path 11. Preferring the Route Sent by the BGP Peer with the

5. Preferring the Route with the Highest Origin Smallest Router ID

Priority (IGP>EGP>Incomplete) 12. Preferring the Route Sent by the Peer with the Lowest

6. Preferring the Route with the Smallest MED IP Address


BGP Route Load Balancing Not Configured

8.8.8.0/24 8.8.8.0/24 8.8.8.0/24 8.8.8.0/24

AS 100 AS 300
R1 R3 R1 AS 123
R3

8. 8. 4
8. 4
8.
0/ /2
8.
8. 0 /2
24 .0 0/ 8.
.8 24 8.
8.
8 8.
R2 R2
AS 200 AS 200
8.8.8.0/24 8.8.8.0/24

AS 400 R4 AS 400
R4

After R2 learns two EBGP routes to 8.8.8.0/24, R2 After R2 learns two IBGP routes to 8.8.8.0/24, R2
then selects only one optimal route, adds it to the then selects only one optimal route, adds it to the
routing table, and sends it to R4. routing table, and sends it to R4.
BGP Route Load Balancing

• On large-scale networks, there are usually multiple valid BGP routes to the same destination. Among these routes,
a device selects only one optimal BGP route, adds it to the routing table, and advertises only the optimal route to p
eers. In this case, traffic loads may be unbalanced. BGP route load balancing can address this problem. With BGP
route load balancing, multiple equal-cost BGP routes are added to the routing table, which reduces network conges
tion.

• Although BGP load balancing is configured, a device selects only one optimal route from multiple BGP routes to th
e same destination and advertises only the optimal route to peers.

• For BGP route load balancing to take effect, the attributes involved in the first eight rules must be the same.
BGP Route Load Balancing

• If BGP load balancing is configured, the local device changes the next hop address to its address regardless of wh
ether the peer next-hop-local command is run.

• By default, traffic cannot be balanced among IBGP and EBGP routes on the public network. If multiple routes with
the same destination address exist on the public network, the system selects the optimal route first. If the optimal
route is an IBGP route, only IBGP routes carry out load balancing. If the optimal route is an EBGP route, only
EBGP routes carry out load balancing.

• If there are multiple routes to the same destination address but these routes pass through different ASs, load balan
cing cannot be implemented by default. To allow these routes to participate in load balancing, run the load-balanci
ng as-path-ignore command. However, exercise caution when running this command because it changes the con
ditions of route load balancing.

• The load-balancing as-path-ignore and bestroute as-path-ignore commands are mutually exclusive.0
BGP Route Load Balancing

8.8.8.0/24 8.8.8.0/24

AS 100 AS 300
R1 R3 [R2-bgp] maximum load-balancing ebgp 2
//Set the maximum number of equal-cost EBGP routes for
8.
AS 8.8 24
0/ 00
load balancing to 2. The default value is 1, indicating that load
_P .0/2 8.
at 4 8. =3 balancing is not performed.
h= 8. ath
10
0 _P
AS [R2-bgp] load-balancing as-path-ignore
AS 200 R2 //The AS_Path attributes of the two routes advertised by R1
8.8.8.0/24
and R3 are different. Therefore, this command needs to be
configured so that the AS_Path attributes of the routes are not
compared during load balancing. Exercise caution when runni
AS 400 ng this command because it may lead to routing loops.
R4

R2 learns two EBGP routes to 8.8.8.0/24. Route attributes of the two routes are the same except the AS_Path attribute. By
default, R2 selects only one optimal route and advertises it to R4. After the maximum load-balancing ebgp 2 command is run
on R2, R2 adds the two equal-cost EBGP routes to the routing table for load balancing.
BGP Route Load Balancing

<R2>display ip routing-table protocol bgp Equal-cost routes to 8.8.8.0/24 participate in load


Route Flags: R - relay, D - download to fib balancing and are displayed in the IP routing table
------------------------------------------------------------------------------ of R2.
Destination/Mask Proto Pre Cost Flags NextHop Interface
8.8.8.0/24 EBGP 255 0 D 10.1.12.1 GigabitEthernet0/0/0
EBGP 255 0 D 10.1.23.3 GigabitEthernet0/0/1

<R2>display bgp routing-table In the BGP routing table of R2, only one BGP route
BGP Local router ID is 10.1.12.2 is selected as the optimal route and is advertised to
Status codes: * - valid, > - best, d - damped, R4.
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 8.8.8.0/24 10.1.12.1 0 0 100i
* 10.1.23.3 0 0 300i
BGP Route Load Balancing

8.8.8.0/24 8.8.8.0/24

R1 AS123
R3

8. 4
8.
8. 0 /2
0/ 8.
24 8.
8.
[R2-bgp] maximum load-balancing ibgp 2 R2
AS200
//Set the maximum number of equal-cost IBGP routes for
8.8.8.0/24
load balancing to 2. The default value is 1, indicating that
load balancing is not performed.

R4 AS400

R2 learns two IBGP routes to 8.8.8.0/24, and the path attributes of the two routes are the same. Therefore, R2 selects only one
optimal route and advertises it to R4. After the maximum load-balancing ibgp 2 command is run on R2, R2 adds the two
equal-cost IBGP routes to the routing table for load balancing.
BGP Route Load Balancing

<R2>display ip routing-table protocol bgp Equal-cost routes to 8.8.8.0/24 participate in


Route Flags: R - relay, D - download to fib load balancing and are displayed in the IP
------------------------------------------------------------------------------ routing table of R2.
Destination/Mask Proto Pre Cost Flags NextHop Interface
8.8.8.0/24 IBGP 255 0 RD 1.1.1.1 GigabitEthernet0/0/0
IBGP 255 0 RD 3.3.3.3 GigabitEthernet0/0/1

<R2>display bgp routing-table In the BGP routing table of R2, only one BGP
BGP Local router ID is 10.1.12.2 route is selected as the optimal route and is
Status codes: * - valid, > - best, d - damped, advertised to R4.
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 8.8.8.0/24 1.1.1.1 0 100 0 i
*i 3.3.3.3 0 100 0 i
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to

2. Preferring the Route with the Largest the Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load

3. Preferring Locally Originated Routes Balancing (If Configured)

4. Preferring the Route with the Shortest AS_Path 10. Preferring the Route with the Shortest Cluster_List

5. Preferring the Route with the Highest Origin 11. Preferring the Route Sent by the BGP Peer with the

Priority (IGP>EGP>Incomplete) Smallest Router ID

6. Preferring the Route with the Smallest MED 12. Preferring the Route Sent by the Peer with the

Lowest IP Address
Preferring the Route with the Shortest Cluster_List (Example 1)

11.11.11.0/24 • An IBGP peer relationship is established between R1


and R2, between R1 and R3, between R3 and R4,
R1 between R2 and R5, and between R4 and R5 using
loopback interfaces.
• R2 is an RR, and R1 is its client.
• R3 is an RR, and R1 is its client.
R2 R3
RR RR
• R4 is an RR, and R3 is its client.
• R1 imports the route 11.11.11.0/24 to BGP.
• R5 learns the BGP routes destined for 11.11.11.0/24
R4
from R2 and R4. R5 cannot select the optimal route
RR
according to the preceding rules. In this case, R5
preferentially selects the route with the shortest
R5
Cluster_List (the route advertised by R2) according to
AS 64512
this rule.
BGP route BGP route
Preferring the Route with the Shortest Cluster_List (Example 2)

100.0.1.0/24 100.0.1.0/24

R1 R2
• An IBGP peer relationship is established
100.0.1.0/24 AS 100 AS 200 between R3 and R4, between R4 and R5, and
between R3 and R5 using loopback interfaces.

100.0.1.0/24 • R4 is an RR, and R3 is its client.


R3 R5 • R1 imports the route 100.0.1.0/24 to BGP. R5
learns the BGP routes destined for 100.0.1.0/24
from R3 and R4. Which route should be
selected as the optimal route?
BGP route AS 345
R4
R4
Preferring the Route with the Shortest Cluster_List (Example 2)

[R5-bgp]display bgp routing-table 100.0.1.0

BGP routing table entry information of 100.0.1.0/24:


From: 3.3.3.3 (3.3.3.3)
...
AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best
, select, active, pre 255, IGP cost 2

BGP routing table entry information of 100.0.1.0/24:


From: 4.4.4.4 (4.4.4.4)
...
AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre
255, IGP cost 2, not preferred for Cluster List
Originator: 3.3.3.3 Indicates the reason why the route
Cluster list: 4.4.4.4 advertised by R4 is not preferred.
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load

3. Preferring Locally Originated Routes Balancing (If Configured)

4. Preferring the Route with the Shortest 10. Preferring the Route with the Shortest Cluster_List

AS_Path 11. Preferring the Route Sent by the BGP Peer with the

5. Preferring the Route with the Highest Origin Smallest Router ID

Priority (IGP>EGP>Incomplete) 12. Preferring the Route Sent by the Peer with the Lowest

6. Preferring the Route with the Smallest MED IP Address


Preferring the Route Sent by the BGP Peer with the Smallest Router ID

100.0.1.0/24 100.0.1.0/24

R1 R2

AS 100 AS 200
100.0.1.0/24 100.0.1.0/24

R3 R5

AS 345 3.3.3.3 R4 5.5.5.5

BGP route

In this topology, no BGP routing policies are deployed. R4 learns the BGP routes to 100.0.1.0/24 from R3 and R5. R4 cannot
select the optimal route using the first 10 rules. In this case, R4 preferentially selects the route advertised by the peer (R3) with
the smallest router ID according to this rule.
Preferring the Route Sent by the BGP Peer with the Smallest Router ID

[R4-bgp]display bgp routing-table 100.0.1.0


...
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 100.0.1.0/24:
From: 3.3.3.3 (3.3.3.3)
...
AS-path 12, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best,
select, active, pre 255, IGP cost 1 Router ID comparison

BGP routing table entry information of 100.0.1.0/24:


From: 5.5.5.5 (5.5.5.5)
...
AS-path 12, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre 2
55, IGP cost 1, not preferred for router ID
Rule Supplement

• Rule supplement: If routes carry the Originator_ID attribute, the router compares the Originator_IDs rather than rout
er IDs and preferentially selects the route with the smallest Originator_ID.

8.8.8.0/24 1. The two routes have the same Preferred_Value and Local_Preference.
2. The two routes are not originated locally.
R4 3. The two routes have the same AS_Path length.
4. The two routes have the same Origin.
5. The two routes have the same MED.
6. The two routes are both IBGP routes.
Reflection Reflection
7. The two routes have the same Next_Hop.

R1 R3 8. The two routes have the same Cluster_List length.


RR RR 9. Because the two routes carry the Originator_ID attribute, R2 compares the Or
iginator_IDs the routes. However, the two routes have the same Originator_I
D.
AS 1234
R2 10. R2 uses the last rule to select the optimal route.
Contents

1. Preferring the Route with the Largest 7. Preferring the Route Advertised by an EBGP Peer

Preferred_Value 8. Preferring the Route with the Smallest IGP Cost to the

2. Preferring the Route with the Largest Next_Hop

Local_Preference 9. Allowing Multiple Routes to Participate in Load Balancing

3. Preferring Locally Originated Routes (If Configured)

4. Preferring the Route with the Shortest 10. Preferring the Route with the Shortest Cluster_List

AS_Path 11. Preferring the Route Sent by the BGP Peer with the

5. Preferring the Route with the Highest Origin Smallest Router ID

Priority (IGP>EGP>Incomplete) 12. Preferring the Route Sent by the Peer with the Lowest

6. Preferring the Route with the Smallest MED IP Address


Preferring the Route Sent by the Peer with the Lowest IP Address

8.8.8.0/24 1. The two routes have the same Preferred_Value and Local_Preference.
2. The two routes are not originated locally.
R4
3. The two routes have the same AS_Path length.
4. The two routes have the same Origin.
5. The two routes have the same MED.
6. The two routes are both IBGP routes.
Reflection Reflection
7. The two routes have the same Next_Hop.
R1 R3 8. The two routes have the same Cluster_List length.
RR RR
9. Because the two routes carry the Originator_ID attribute, R2 compares the Origin
ator_IDs the routes. However, the two routes have the same Originator_ID.
10. The route sent by the BGP peer (R1) with the smallest peer IP address is preferr
AS1234
R2
ed.
Note: The peer IP address is the one specified in the peer command in the BGP vie
w of R2 when a peer relationship is established between R1 and R2, or between
R2 and R3.
Preferring the Route Sent by the Peer with the Lowest IP Address

[R2]dis bgp ro 44.44.44.0

BGP routing table entry information of 44.44.44.0/24:


From: 1.1.1.1 (1.1.1.1)
...
AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best
, select, active, pre 255, IGP cost 2
Originator: 4.4.4.4
Cluster list: 1.1.1.1

BGP routing table entry information of 44.44.44.0/24:


From: 3.3.3.3 (3.3.3.3)
...
AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre
255, IGP cost 2, not preferred for peer address
Originator: 4.4.4.4 Indicates the reason why the route
Cluster list: 3.3.3.3 advertised by R3 is not selected.

You might also like