Sie sind auf Seite 1von 83

Special Topic - BGP Route Selection

Issue 1.0
Date 2014-6-12

HUAWEI TECHNOLOGIES CO., LTD.


Copyright © Huawei Technologies Co., Ltd. 2014. All rights reserved.
No part of this document may be reproduced or transmitted in any form or by any means without prior written
consent of Huawei Technologies Co., Ltd.

Trademarks and Permissions

and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.
All other trademarks and trade names mentioned in this document are the property of their respective holders.

Notice
The purchased products, services and features are stipulated by the contract made between Huawei and the
customer. All or part of the products, services and features described in this document may not be within the
purchase scope or the usage scope. Unless otherwise specified in the contract, all statements, information,
and recommendations in this document are provided "AS IS" without warranties, guarantees or representations
of any kind, either express or implied.

The information in this document is subject to change without notice. Every effort has been made in the
preparation of this document to ensure accuracy of the contents, but all statements, information, and
recommendations in this document do not constitute a warranty of any kind, express or implied.

Huawei Technologies Co., Ltd.


Address: Huawei Industrial Base
Bantian, Longgang
Shenzhen 518129
People's Republic of China

Website: http://www.huawei.com
Email: support@huawei.com

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential i


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection About This Document

About This Document

Overview
This document describes detailed BGP route selection rules on Huawei devices using VRP
software platform.

Intended Audience
This document is intended for:

l Network Planning Engineers


l Commissioning Engineer
l Data Configuration Engineer
l Network Monitoring Engineer
l System Maintenance Engineer

Command Conventions
Convention Description

Boldface The keywords of a command line are in boldface.

Italic Command arguments are in italics.

[] Items (keywords or arguments) in brackets [ ] are optional.

{ x | y | ... } Optional items are grouped in braces and separated by vertical


bars. One item is selected.

[ x | y | ... ] Optional items are grouped in brackets and separated by vertical


bars. One item is selected or no item is selected.

{ x | y | ... } * Optional items are grouped in braces and separated by vertical


bars. A minimum of one item or a maximum of all items can be
selected.

[ x | y | ... ] * Optional items are grouped in brackets and separated by vertical


bars. Several items or no item can be selected.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential ii


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection About This Document

Convention Description

&<1-n> The parameter before the & sign can be repeated 1 to n times.

# A line starting with the # sign is comments.

Change History
Version Release Date Change History

1.0 2014-06-12 First version.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential iii


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection Contents

Contents

About This Document.....................................................................................................................ii


1 Route Processing on the BGP Router........................................................................................1
2 BGP Route Selection Rules.........................................................................................................3
3 BGP Routing Table.......................................................................................................................9
4 Route Attributes...........................................................................................................................15
4.1 Next_Hop......................................................................................................................................................................17
4.2 PrefVal..........................................................................................................................................................................23
4.3 Local_Pref....................................................................................................................................................................28
4.4 Route Type...................................................................................................................................................................41
4.5 AIGP.............................................................................................................................................................................44
4.6 AS_Path........................................................................................................................................................................48
4.7 Origin............................................................................................................................................................................56
4.8 MED.............................................................................................................................................................................60
4.9 Peer Type......................................................................................................................................................................68
4.10 IGP Cost.....................................................................................................................................................................69
4.11 Cluster_List................................................................................................................................................................72
4.12 Originator_ID.............................................................................................................................................................74
4.13 Router ID....................................................................................................................................................................76
4.14 Peer IP Address..........................................................................................................................................................77

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential iv


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 1 Route Processing on the BGP Router

1 Route Processing on the BGP Router

This section describes the route processing on the BGP Router.

Figure 1-1 shows the route processing on the BGP Router. BGP routes can be imported from
other protocols or learned from BGP peers. Route summarization can be configured to reduce
the routing table size before routes are selected, advertised, and delivered to the IP routing table.

Figure 1-1 Route processing on the BGP Router

1 2
Direct Routing 3 4 5 2
Static policy
IGP BGP
Route Route Export
routing BGP
summarization selection policy
table peers
2
BGP 入口
Import
peers 策略
policy
6
Routes learned from BGP peers

IP routing
table

Table 1-1 lists some key points for Figure 1-1.

Table 1-1 Key points for route processing

No. Remarks

1 BGP can import direct routes, static routes, user network routes, and IGP routes based
on the import-route (BGP) or network command configuration.

2 BGP can use routing polices when importing routes from other protocols, receiving
routes from BGP peers, or advertising routes to BGP peers. Routing polices can be
used to filter routes or modify route attributes.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 1


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 1 Route Processing on the BGP Router

No. Remarks

3 BGP supports automatic and manual summarization. Multiple routing policies can be
used during manual summarization.

4 BGP selects routes based on strict route selection rules, which is the key point to be
discussed in the following part.

5 BGP adds the optimal route to the BGP routing table and advertises it to BGP peers.

6 BGP adds the routes learned from peers and the optimal route in the BGP routing table
to the IP routing table for traffic forwarding.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 2


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 2 BGP Route Selection Rules

2 BGP Route Selection Rules

When multiple routes are available to the same destination, BGP selects one optimal route based
on BGP route selection rules and adds it to the IP routing table for traffic forwarding.

Figure 2-1 shows how the optimal route is selected in the V600R006 and the earlier versions.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 3


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 2 BGP Route Selection Rules

Figure 2-1 BGP route selection process (in V600R006 and the earlier versions)
Multiple routes to the same No The route is
Is the next hop address reachable?
destination are available. ignored.
Yes

Are PrefVal values The route with the largest PrefVal


the same? No value is preferred.
Yes

Are Local_Pref values The route with the largest


the same? No Local_Pref value is preferred.
Yes

Are they generated Aggregate>Summary>Network


the same way? No >Import>Learned from peers
Yes

Are AS_Path lengths The route with the shortest AS_Path


the same? No length is preferred.
Yes

Are Origin types IGP > EGP > Incomplete


the same? No

Are MEDs The one with the smallest MED


the same? value is preferred.
No
Yes

Are peer types EBGP > IBGP


the same? No
Yes
Are IGP costs The one with the smallest IGP cost
the same? No value is preferred.
Yes

Are Cluster_List lengths The route with the shortest


the same? No Cluster_List length is preferred.

Yes
Are router IDs The route with the smallest router ID
the same? No is preferred.
Yes

Are peer addresses The route with the smallest peer The optimal
the same? No address is preferred. route is selected.

Figure 2-2 shows how the optimal route is selected in V600R007C00 and the later versions.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 4


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 2 BGP Route Selection Rules

Figure 2-2 BGP route selection process (in V600R007 and the later versions)
Multiple routes to the same No The route is
Is the next hop address reachable?
destination are available. ignored.
Yes

Are PrefVal values The route with the largest PrefVal


the same? No value is preferred.
Yes
Are Local_Pref values The route with the largest
the same? No Local_Pref value is preferred.
Yes
Are they generated Aggregate>Summary>Network
the same way? No >Import>Learned from peers
Yes
The route with the smallest AIGP is
Are AIGP values
preferred, and the route with AIGP is
the same? No preferred to the route without AIGP.
Yes
Are AS_Path lengths The route with the shortest AS_Path
the same? No length is preferred.
Yes
Are Origin types IGP > EGP > Incomplete
the same? No

Are MEDs The one with the smallest MED


the same? No value is preferred.
Yes
Are peer types EBGP > IBGP
the same? No
Yes
Are IGP costs The one with the smallest IGP cost
the same? No value is preferred.
Yes

Are Cluster_List lengths The route with the shortest


the same? No Cluster_List length is preferred.

Yes
Are router IDs The route with the smallest router ID
the same? No is preferred.
Yes
Are peer addresses The route with the smallest peer The optimal
the same? No address is preferred. route is selected.

BGP selects routes by comparing route attributes in a fixed order. When a route attribute is a
sufficient condition for determining the optimal route, BGP does not compare the other
attributes; If BGP fails to select the optimal route after comparing all route attributes, the route
that was first received is selected as the optimal route.Table 2-1 lists the abbreviated alias, route
selection rules, and remarks of each matching item. Table 2-1 shows that the route priority is
directly proportional to the PreVal or Local_Pref value and inversely proportional to the rest of
the attribute values or lengths. In addition, the first column can be summarized as a character
string ("PPAA OMTCC RA" for V600R006 and the earlier versions, "PPAAA OMTCC RA"
for V600R007 and the later versions), which helps memorize the matching sequence.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 5


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 2 BGP Route Selection Rules

Table 2-1 BGP route selection process

Abbr Matching Route Selection Rules Remarks


eviate Item
d
Alias

P PrefVal The route with the largest PrefVal is Huawei-specific and valid
PreVal value is preferred. only on the device where it is
The default value is 0. configured.

P Local_Pref The route with the largest To modify the default Local_Pref
Local_Pref value is value of BGP routes, run the default
preferred. local-preference command.
The default value is 100.

A Route type A > S > N > I > L, in -


NOTE which:
A is l A: indicates that
the
routes are
initia
l of summarized using the
the aggregate command.
chara l S: indicates that routes
cter
are summarized using
strin
g the summary
(AS automatic command.
NIL). l N: indicates that
routes are imported
using the network
command.
l I: indicates that routes
are imported using the
import-route
command.
l L: indicates that
routes are learned
from BGP peers.

A Accumulated The route with the -


Interior smallest AIGP value is
Gateway preferred.
Protocol The route with AIGP to
(AIGP) the route without AIGP is
preferred.

A AS_Path The route with the If the bestroute as-path-ignore


shortest AS_Path length command is configured, BGP does not
is preferred. compare the AS_Path attribute.

O Origin IGP > EGP > Incomplete -

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 6


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 2 BGP Route Selection Rules

Abbr Matching Route Selection Rules Remarks


eviate Item
d
Alias

M Multi Exit The route with the If the bestroute med-none-as-


Discriminator smallest MED value is maximum command is configured,
(MED) preferred. BGP considers the largest MED value
The default value is 0. (4294967295) as the MED of the route
that does not carry an MED.
For details about MED usage, see
MED.

T Peer type EBGP > IBGP -

C IGP cost The route with the In V600R007C00 and the later
smallest IGP cost is versions, if the bestroute igp-metric-
preferred. ignore command is configured, BGP
does not compare the IGP cost.

C Cluster_List The route with the In V600R008C00 and the later


shortest Cluster_List versions, by default, Cluster_List
length is preferred. takes precedence over Originator_ID
during BGP route selection. To enable
Originator_ID to take precedence over
Cluster_List during BGP route
selection, run the bestroute routerid-
prior-clusterlist command.

R Router ID The route with the If routes carry the Originator_ID, the
smallest router ID is originator ID is substituted for the
preferred. router ID during route selection. The
route with the smallest Originator_ID
is preferred.

A Peer IP The route learned from -


address the peer with the smallest
IP address is preferred.

Selection of the Routes for Load Balancing


After BGP load balancing is configured, the BGP routes that meet the following conditions are
used as equal-cost routes for load balancing:

l The routes have the same PrefVal value.


l The routes have the same Local_Pref value.
l All the routes are summarized or non-summarized routes.
l The routes have the same AIGP value in V600R007C00 and the later versions.
l The routes have the same AS_Path length.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 7


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 2 BGP Route Selection Rules

l The routes have the same origin type (IGP, EGP, or incomplete).
l The routes have the same MED value.
l All the routes are EBGP or IBGP routes. After the maximum load-balancing eibgp
command is run, BGP ignores this limitation when selecting the optimal VPN route.
l The costs of the IGP routes to which the BGP routes are iterated within an AS are the same.
After the maximum load-balancing eibgp command is run, BGP ignores this limitation
when selecting the optimal VPN route.

In addition, BGP labeled routes and non-labeled routes cannot load-balance traffic even if they
meet the preceding conditions.

VPN Route Selection Rules


BGP VPN routes are selected in the same way as BGP public routes except that VPN target-
based route crossing is implemented first on BGP VPN routes. For details about BGP VPN route
crossing, see "VPN Route Crossing" in Feature Description - IP Routing - BGP.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 8


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 3 BGP Routing Table

3 BGP Routing Table

This section describes how to check route attributes.

Table 3-1 lists all the common route attributes that affect route selection and the commands that
are used to check them.

Table 3-1 Commands used to check route attributes

Route Command Used to Check the Route Attribute


Attribute

PrefVal display bgp routing-table [ network ]

Local_Pref display bgp routing-table [ network ]

Route type display bgp routing-table network

AIGP display bgp routing-table network

AS_Path display bgp routing-table [ network ]

Origin display bgp routing-table [ network ]

MED display bgp routing-table [ network ]

Peer type display bgp routing-table network

IGP cost l display bgp routing-table network


l display ip routing-table ip-address [ mask | mask-length ] [ verbose ],
in which ip-address is the next hop IP address of a BGP route

Cluster_List display bgp routing-table network

Originator_ID display bgp routing-table network

Router ID display bgp routing-table network

Peer IP display bgp routing-table network


address

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 9


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 3 BGP Routing Table

The following example describes how to check BGP route attributes in the display bgp routing-
table command output.
<HUAWEI> display bgp routing-table

BGP Local router ID is 192.168.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: 9


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 1.1.1.9/32 0.0.0.0 0 0 i


*>i 2.2.2.7/32 10.1.1.2 0 100 0 (65001)i
* i 10.1.3.1 0 100 0 (65011 65001)
i
*>i 2.2.2.8/32 10.1.2.2 0 100 0 (65011)i
* i 10.1.3.2 0 100 0 (65001 65011)
i
*>i 2.2.2.9/32 10.1.4.2 0 100 0 (65001 65101)
i
* i 10.1.5.2 0 100 0 (65011 65101)
i
i 3.3.3.9/32 10.1.6.2 0 100 0 (65001 65101)
300i
i 10.1.6.2 0 100 0 (65011 65001
65101) 300i

Table 3-2 Description of the display bgp routing-table command output

Item Description

BGP Local
router ID is
1.1.1.2 Router ID: 1.1.1.2, in the same format as an IPv4 address

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 10


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 3 BGP Routing Table

Item Description

Route status code, displayed in front of each route entry:


l *: indicates a valid route with a reachable next hop address.
l >: indicates an optimal route selected by BGP.
l d: indicates a dampened route.
l h: indicates a History route.
l i: indicates a route learned from an IBGP peer.
l s: indicates a suppressed route. If specific routes for route summarization
are suppressed, s is displayed in front of each specific route.
l S: indicates a route in Stale status, and the route is being deleted. Such
routes may occur during a BGP GR process.
BGP dampening measures route stability using a penalty value. The greater
the penalty value, the less stable a route. Each time route flapping occurs (a
device receives a Withdraw or an Update packet), BGP adds a penalty value
to the route carried in the packet.
When the penalty value of a route exceeds the Suppress value, BGP
suppresses the route by replacing the > sign of the route with the d or h sign.
The route is ignored and its Update packets are not advertised to other BGP
peers until the penalty value of the route decreases to the Reuse value.
l If d is displayed in front of a route, the route is carried in an Update packet.
l If h is displayed in front of a route, the route is carried in a Withdraw
packet.
The penalty value is not increased after it reaches the suppression threshold.
The penalty value of a suppressed route reduces by half after a half-life period.
l When the penalty value of a route with the d sign decreases to the Reuse
value, the route becomes reusable, and BGP removes the d sign, adds the
route to the IP routing table, and advertises an Update packet carrying the
route to BGP peers.
l When the penalty value of a route with the h sign decreases to 0, BGP
Status codes deletes this route from the BGP routing table.

Route origin code, displayed in front of each route entry:


l IGP: indicates that routes are added to the BGP routing table using the
network (BGP) command.
l EGP: indicates that routes are learned through the EGP protocol.
l Incomplete: indicates that routes are added to the BGP routing table using
Origin the import-route (BGP) command.

Network Network address in the BGP routing table

NextHop Next hop address

MED MED value of a BGP route, similar to the cost of IGP routes

LocPrf Local_Pref

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 11


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 3 BGP Routing Table

Item Description

PrefVal PrefVal

Path/Ogn AS_Path and Origin attributes

Information about Next_Hop, MED, Local_Pref, PrefVal, AS_Path, and Origin can be displayed
using the display bgp routing-table command. To check information about the route type,
AIGP, peer type, IGP cost, Cluster_List, router ID, and peer IP address, run the display bgp
routing-table network command.
<HUAWEI> display bgp routing-table 10.1.1.1

BGP local router ID : 192.168.2.2


Local AS number : 65001
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 10.1.1.1/32:
From: 10.1.3.1 (192.168.2.3)
Route Duration: 05h35m04s
Relay IP Nexthop: 0.0.0.0
Relay IP Out-Interface: GigabitEthernet1/0/4
Original nexthop: 10.1.3.1
Qos information : 0x0
AS-path Nil, origin incomplete, MED 1234, localpref 100, pref-val 0, valid,
internal, best, select, active, pre 255, IGP cost 1, AIGP 1
Not advertised to any peer yet

Table 3-3 Description of the display bgp routing-table command output

Item Description

BGP local router Router ID of the local device, in the same format as an IPv4 address.
ID

Local AS number Local AS number.

Paths BGP route information.

BGP routing table Information about the BGP route 10.1.1.1/32:


entry information
of 10.1.1.1/32

From IP address of the device that advertised the route. In this example,
10.1.3.1 is the IP address of the interface used by the peer to establish
the BGP peer relationship (peer IP address), and 192.168.2.3 is the
router ID of the peer.

Route Duration Duration of a route.

Relay IP Nexthop IP address of the route to which the BGP route is iterated.

Relay IP Out- Outbound interface of the route to which the BGP route is iterated.
Interface

Original nexthop Original next hop IP address.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 12


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 3 BGP Routing Table

Item Description

Qos information QoS information.

AS-path AS_Path attribute. If Nil is displayed, the AS_Path attribute is null.

origin incomplete Origin attribute:


l IGP: indicates that routes are added to the BGP routing table using
the network (BGP) command.
l EGP: indicates that routes are learned through the EGP protocol.
l Incomplete: indicates that routes are imported using the import-
route (BGP) command.

MED MED value of a BGP route, similar to the cost of IGP routes.

localpref Local_Pref

pref-val PrefVal

valid Valid route with a reachable next hop address.

internal Type of the peer from which the route is learned.


l external: indicates that the route is learned from an EBGP peer.
l internal: indicates that the route is learned from an IBGP peer.

best Optimal route.

select Selected route to be delivered to the IP routing table.


NOTE
According to BGP selection rules, BGP selects only one optimal route, and this
route is marked with best. In load balancing or FRR scenarios, more than one
route needs to be added to the IP routing table, and each of the route is marked
with select. Therefore, the number of the route marked with best is 1, and the
number of the routes marked with select is the actual number of routes added to
the IP routing table.

active Active route.

pre 255 Protocol priority of the route: 255

IGP cost IGP cost.

AIGP AIGP

Not advertised to The route has not advertised to any peer yet.
any peer yet

The display bgp routing-table network [ { mask | mask-length } [ longer-prefixes ] ] command


output varies with the route generation mode and transmission mode, and not all BGP attributes
are necessarily displayed. In the preceding example, the route type is not displayed because the
route 12.13.14.15/32 is an IBGP route. If you run the display bgp routing-table network
[ { mask | mask-length } [ longer-prefixes ] ] command, the route type will be displayed. For
example:

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 13


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 3 BGP Routing Table

<HUAWEI> display bgp routing-table 10.0.0.0

BGP local router ID : 192.168.2.4


Local AS number : 200
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 10.0.0.0/8:
Aggregated route.
Route Duration: 04h50m46s
Direct Out-interface: NULL0
Original nexthop: 127.0.0.1
Qos information : 0x0
AS-path {65001 10 100}, origin incomplete, pref-val 0, valid, local, best, select,
active, pre 255
Aggregator: AS 200, Aggregator ID 192.168.2.4, Atomic-aggregate
Advertised to such 3 peers:
10.1.7.2
172.16.1.2
192.168.1.2

The route 10.0.0.0/8 was manually summarized using the aggregate command. Therefore,
Aggregated route is displayed in the command output. The route type varies as follows:
l If the route is automatically summarized using the summary automatic command,
Summary automatic route will be displayed.
l If the route is imported using the network command, Network route will be displayed.
l If the route is imported using the import-route command, Imported route will be
displayed.

In the following example, an RR and a cluster are configured. Therefore, the Cluster_List
attribute is displayed in the display bgp routing-table network [ { mask | mask-length } [ longer-
prefixes ] ] command output.
<HUAWEI> display bgp routing-table 10.2.1.0

BGP local router ID : 4.4.4.4


Local AS number : 65010
Paths: 1 available, 0 best, 0 select
BGP routing table entry information of 10.2.1.0/24:
From: 10.1.4.1 (2.2.2.2)
Route Duration: 00h00m14s
Relay IP Nexthop: 0.0.0.0
Relay IP Out-Interface:
Original nexthop: 10.1.1.2
Qos information : 0x0
AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, internal, pre 255
Originator: 1.1.1.1
Cluster list: 0.0.0.1
Not advertised to any peer yet

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 14


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

4 Route Attributes

About This Chapter

4.1 Next_Hop
BGP ignores routes with an unreachable next hop address during BGP route selection.

4.2 PrefVal
BGP prefers the route with the largest PreVal value during BGP route selection.

4.3 Local_Pref
BGP prefers the route with the highest Local_Pref during BGP route selection.

4.4 Route Type


BGP prefers locally imported routes to the routes learned from peers during BGP route selection.

4.5 AIGP
BGP prefers the route with the smallest AIGP value during BGP route selection.

4.6 AS_Path
BGP prefers the route with the shortest AS_Path length (the number of included ASs) during
BGP route selection.

4.7 Origin
The Origin attribute indicates how routes become BGP routes.

4.8 MED
MED attributes of routes can be configured as required to control traffic forwarding path for the
purpose of load balancing.

4.9 Peer Type


When IBGP routes (routes learned from IBGP peers) and EBGP routes (routes learned from
EBGP peers) are available, BGP preferentially selects EBGP routes.

4.10 IGP Cost


BGP prefers the route with the smallest IGP cost during BGP route selection.

4.11 Cluster_List
BGP prefers the route with the shortest Cluster_List length during BGP route selection.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 15


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

4.12 Originator_ID
If routes carry the Originator_ID, the originator ID is substituted for the router ID during route
selection. The route with the smallest Originator_ID is preferred.

4.13 Router ID
If multiple routes to the same destination are available, BGP preferentially selects the route
advertised by the device with the smallest router ID.

4.14 Peer IP Address


BGP prefers the route learned from the peer with the smallest IP address during BGP route
selection.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 16


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

4.1 Next_Hop
BGP ignores routes with an unreachable next hop address during BGP route selection.

Unlike the Next_Hop attribute in an IGP, the Next_Hop attribute in BGP is not necessarily the
IP address of a neighboring device. In most cases, the Next_Hop attribute in BGP complies with
the following rules:

l When advertising a route to an EBGP peer, a BGP speaker sets the Next_Hop of the route
to the address of the local interface through which the BGP peer relationship is established.
l When advertising a locally generated route to an IBGP peer, a BGP speaker sets the
Next_Hop of the route to the address of the local interface through which the BGP peer
relationship is established.
l When advertising a route learned from an EBGP peer to an IBGP peer, the BGP speaker
does not modify the Next_Hop of the route.

Modifying the Next_Hop


In some scenarios, the Next_Hop needs to be modified. Table 4-1 describes whether the
Next_Hop needs to be modified in specific scenarios.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 17


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Table 4-1 Next_Hop processing

Objectives Command Usage Scenarios Remarks

To enable an peer { ipv4-address | By default, when an ASBR If BGP load


ASBR to group-name } next- forwards a route learned balancing has been
modify the hop-local from an EBGP peer to its configured using the
Next_Hops of IBGP peers, the ASBR maximum load-
the routes to be does not change the balancing number
advertised to Next_Hop of the route. command, the device
IBGP peers. Therefore, the Next_Hop modifies the
address of the route Next_Hop of each
remains the EBGP peer IP route to the local IP
address. After being address through
forwarded to the IBGP which the IBGP peer
peers, the route cannot relationship is
become active as the established before it
Next_Hop is unreachable. advertises the route
To address this issue, to IBGP peers,
configure the ASBR to regardless of whether
modify the Next_Hop of the peer next-hop-
the route to the local IP local command is
address before advertising configured.
the route to IBGP peers.
After being forwarded to
the IBGP peers, the route
can be active because the
Next_Hop is reachable (an
IGP is configured in the
AS).

To prevent a peer { ipv4-address | - By default, a device


device from group-name } next- modifies the
modifying the hop-invariable Next_Hops of the
Next_Hops of routes imported from
the routes an IGP to the local IP
imported from address before
an IGP before advertising the routes
advertising the to IBGP peers.
routes to IBGP
peers.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 18


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Objectives Command Usage Scenarios Remarks

To prevent a peer { group-name | In an inter-AS VPN Option By default, a device


device from ipv4-address } next- C scenario where an RR is modifies the
modifying the hop-invariable used, the peer next-hop- Next_Hops of routes
Next_Hops of invariable command to the local IP
routes before needs to be run on the RR address before
advertising the to prevent the RR from advertising the routes
routes to modifying the Next_Hops to EBGP peers.
EBGP peers. of routes before In addition, a device
advertising the routes to does not modify the
EBGP peers. This ensures Next_Hops of non-
that the remote PE iterates labeled routes if the
routes to the LSP destined routes are learned
for the local PE during from EBGP peers
traffic transmission. and are to be
advertised to IBGP
peers; the device sets
its interface IP
address as the
Next_Hops of
labeled routes if the
routes are learned
from EBGP peers
and are to be
advertised to IBGP
peers.

To configure nexthop recursive- To enable a device to By default,


BGP lookup route-policy iterate only desired routes, Next_Hop iteration
Next_Hop route-policy-name configure Next_Hop based on a specified
iteration based iteration based on a route-policy is not
on a route- specified route-policy so configured.
policy. that only the routes that
match the route-policy are
iterated.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 19


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Objectives Command Usage Scenarios Remarks

To enable a apply ip-address The Next_Hops of BGP If a route-policy has


device to next-hop{ ipv4- routes can be modified been specified in the
modify the address | peer- using a route-policy in the import-route or
Next_Hops of address } following situations: network command,
BGP routes l For IBGP peers, the the apply clause
using a route- route-policy can be an configured for the
policy. import or export policy. route-policy using
Even if the next hop the apply ip-address
address configured in next-hop command
the route-policy is does not take effect.
unreachable, the IBGP
peers still add the routes
whose next hop
addresses have been
changed to the address
configured in the route-
policy to the BGP
routing table. However,
the routes are invalid.
l For EBGP peers, the
route-policy can only
be an import policy in
most cases. If the route-
policy is configured as
an export policy, the
routes whose next hop
addresses have been
changed to the address
configured in the route-
policy are discarded by
the EBGP peers
because the next hop
address is unreachable.
When the EBGP peer
relationships are
established on physical
connections, the
Next_Hops of BGP
routes cannot be
modified.

Obtaining a Reachable Next Hop


During route selection, BGP first checks whether the next hop addresses of routes are reachable.
Routes carrying unreachable next hop addresses are invalid and are not selected. Table 4-2
shows how to obtain a reachable next hop IP address or tunnel.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 20


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Table 4-2 Unreachable next hop

Item Description Solutions

Unreachable next hop IP A next hop IP address is Common solutions are as


address obtained through route follows:
iteration, but no active routes l Configure static routes or
to the IP address are available an IGP.
in the IP routing table.
l Run the import-route
command.
l Run the network
command.
Alternatively, you can run the
peer next-hop-local
command to change the
Next_Hop to the local IP
address.

Unreachable next hop tunnel Routes fail to be iterated to Configure a tunnel policy or
tunnels. a tunnel selector to ensure
that the routes can be iterated
to tunnels.

A next hop tunnel is obtained Ensure that the tunnel is


through route iteration, but correctly configured and is
the tunnel is unavailable. Up.

The following example shows how to obtain a reachable next hop IP address. In Figure 4-1, an
IBGP peer relationship is established between Router A and Router B, and an EBGP peer
relationship is established between Router B and Router C. Router A imports the route 1.1.1.9/32,
and Router C imports the route 3.3.3.9/32.

Figure 4-1 Networking

1.1.1.9/32 3.3.3.9/32
10.1.1.1/30 10.1.2.1/30
10.1.1.2/30 10.1.2.2/30
Router A Router B Router C
AS 300 AS 65001

# Display the BGP routing table of Router A.


[Router A] display bgp routing-table

BGP Local router ID is 10.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: 2

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 21


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Network NextHop MED LocPrf PrefVal Path/Ogn

*> 1.1.1.9/32 0.0.0.0 0 0 i


i 3.3.3.9/32 10.1.2.1 0 100 0 65001i

The preceding command output shows that no asterisk (*) is in front of the route 3.3.3.9/32,
which indicates that the route is invalid.

# Display the IP routing table of Router A.


[Router A] display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 5 Routes : 5

Destination/Mask Proto Pre Cost Flags NextHop Interface

1.1.1.9/32 Direct 0 0 D 127.0.0.1 LoopBack1


10.1.1.0/30 Direct 0 0 D 10.1.1.1
GigabitEthernet0/0/0
10.1.1.1/32 Direct 0 0 D 127.0.0.1
GigabitEthernet0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0

The preceding command output shows that the next hop IP address (10.1.2.1) of the route
3.3.3.9/32 is not in the IP routing table, which indicates that the route is not selected due to the
unreachable next hop IP address. The following solutions can address this issue:
l Configure a static route destined for 10.1.2.1/30 on Router A.
l Configure an IGP on Router B and Router C and configure BGP to import the route 10.1.2.1
on Router B. This solution is not applicable to this specific scenario because Router B and
Router C are located in different ASs.
l Run the import-route direct command on Router B. This solution is not optimal because
unnecessary routes may be imported.
l Run the network 10.1.2.0 30 command on Router B to advertise the route 10.1.2.0/30 to
Router A.
l Run the peer 10.1.1.1 next-hop-local command on Router B to configure Router B to
modify the Next_Hop of the route 3.3.3.9/32 before advertising the route to Router A.

In this example, the network 10.1.2.0 30 command is configured on Router B. After the
command is configured, check the BGP routing table of Router A.
[Router A] display bgp routing-table

BGP Local router ID is 10.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: 3


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 1.1.1.9/32 0.0.0.0 0 0 i


*>i 3.3.3.9/32 10.1.2.1 0 100 0 65001i
*>i 10.1.2.0/30 10.1.1.2 0 100 0 i

The preceding command output shows that both * and > are in front of the route 3.3.3.9/32,
which indicates that the route is valid and optimal.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 22


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

4.2 PrefVal
BGP prefers the route with the largest PreVal value during BGP route selection.

PrefVal is Huawei-specific and valid only on the device where it is configured. The PreVal
attribute is set by customers. Therefore, BGP first compares the PreVal values during route
selection.

To configure a PreVal value for the routes learned from a peer or peer group, run the peer
{ group-name | ipv4-address } preferred-value value command.

If multiple routes are available to the same destination, the route with the largest PreVal value
is selected as the optimal route. By default, the PreVal of the routes learned from BGP peers is
0.

Table 4-3 lists two methods to modify the PreVal value.

Table 4-3 Methods to modify the PreVal value

Method Usage Scenario

Run the peer { group-name | ipv4-address } This method sets a PreVal value for the routes
preferred-value value command. learned from a peer or peer group.

Configure an import policy and run the apply This method sets different PreVal values for
preferred-value preferred-value command different routes learned from a peer or peer
to configure an apply clause for the policy. group.
NOTE
If both the methods are used, the method with the
import policy takes effect if routes match the
conditions specified in the peer preferred-value
command and the import policy.

The following example shows how the PreVal value is used during route selection. In Figure
4-2, both ISP1 and ISP2 advertise the routes 10.11.0.0/16 and 10.22.0.0/16 to AS 65001.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 23


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Figure 4-2 PreVal application networking

Internet

10.11.0.0/16
10.22.0.0/16

AS 100

10.1.1.1/30 10.1.4.1/30
ISP2
ISP1 EBGP IBGP AS 200
10.1.1.2/30 10.1.4.2/30
AS 300
10.1.2.2/30 10.1.3.2/30

EBGP EBGP

10.1.2.1/30 10.1.3.1/30

RouterA

Client Network
AS 65001

Scenario 1: When no PreVal value is configured on Router A, check the BGP routing table of
Router A.
[Router A] display bgp routing-table

BGP Local router ID is 10.1.2.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: 4


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 10.11.0.0/16 10.1.3.2 0 200?


* 10.1.2.2 0 300 100?
*> 10.22.0.0/16 10.1.3.2 0 200?
* 10.1.2.2 0 300 100?

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 24


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

The BGP routing table of Router A shows that Router A receives the routes 10.11.0.0/16 and
10.22.0.0/16 from ISP1 and ISP2. Check the information about the route 10.11.0.0/16 on Router
A.
[Router A] display bgp routing-table 10.11.0.0

BGP local router ID : 10.1.2.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.3.2 (10.1.3.2)
Route Duration: 00h08m35s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 10.1.3.2
Qos information : 0x0
AS-path 200, origin incomplete, pref-val 0, valid, external, best, select, active,
pre 255
Advertised to such 2 peers:
10.1.3.2
10.1.2.2
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.2.2 (10.1.2.2)
Route Duration: 00h04m38s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path 300 100, origin incomplete, pref-val 0, valid, external, pre 255, not
preferred for AS-Path
Not advertised to any peer yet

The preceding command output shows that the AS_Path of the route learned from ISP2 is shorter
than that of the route learned from ISP1. Therefore, the route learned from ISP2 is selected as
the optimal route. Table 4-4 shows the route attribute comparison of the routes 10.11.0.0/16
learned from ISP1 and ISP2.

Table 4-4 Route attribute comparison of the route learned from ISP1 and that learned from ISP2

Route Attribute Route Learned Route Learned Comparison


from ISP1 from ISP2

PrefVal 0 0 The same.

Local_Pref - - The same.


NOTE
If a route does not
carry Local_Pref, the
default value 100
takes effect.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path 300 100 200 The route learned


from ISP2 is selected
as the optimal route
because its AS_Path
is shorter than that of
the route learned
from ISP1.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 25


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Scenario 2: The administrator of AS 65001 requires that ISP1 be active and ISP2 be backup for
the traffic to 10.11.0.0/16 and 10.22.0.0/16.
To meet the preceding requirements, run the peer { group-name | ipv4-address } preferred-
value value command on Router A to increase the PrefVal values of the routes learned from
ISP1. This configuration ensures that the routes learned from ISP1 are selected as the optimal
routes. Detailed configurations are as follows:
bgp 65001
#
ipv4-family unicast
peer 10.1.2.2 preferred-value 120 //Set the PrefVal of the routes
learned from AS 300 to 120.

Run the display bgp routing-table [ ip-address ] command to check the configurations.
# Display the routing table of Router A.
[Router A] display bgp routing-table
BGP Local router ID is 10.1.2.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: 4


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 10.11.0.0/16 10.1.2.2 120 300 100?


* 10.1.3.2 0 200?
*> 10.22.0.0/16 10.1.2.2 120 300 100?
* 10.1.3.2 0 200?

The preceding command output shows that Router A selects the routes learned from ISP1.
# Display detailed information about the route 10.11.0.0/16 or 10.22.0.0/16 on Router A. The
route 10.11.0.0/16 is used as an example.
[Router A] display bgp routing-table 10.11.0.0

BGP local router ID : 10.1.2.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.2.2 (10.1.2.2)
Route Duration: 00h05m36s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path 300 100, origin incomplete, pref-val 120, valid, external, best, select,
active, pre 255
Advertised to such 2 peers:
10.1.3.2
10.1.2.2
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.3.2 (10.1.3.2)
Route Duration: 00h23m11s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 10.1.3.2
Qos information : 0x0
AS-path 200, origin incomplete, pref-val 0, valid, external, pre 255, not
preferred for PreVal
Not advertised to any peer yet

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 26


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

The preceding command output shows that the PrefVal value of the route learned from ISP1 is
greater than that of the route learned from ISP2 and that the route learned from ISP1 is selected
as the optimal route.

Scenario 3: The expected configurations of the administrator of AS 65001 are as follows:

l For the traffic destined to 10.11.0.0/16, ISP1 is active and ISP2 is backup.
l For the traffic destined to 10.22.0.0/16, ISP2 is active and ISP1 is backup.

To meet the preceding requirements, ensure that Router A selects the route 10.11.0.0/16 learned
from ISP1 and the route 10.22.0.0/16 learned from ISP2. In this situation, the peer preferred-
value command can no longer be used because different PrefVal values are required for the
routes learned from the same ISP. To allow different PrefVal values for the routes learned from
the same ISP, configure import policies. Detailed configurations are as follows:
#
bgp 65001
#
ipv4-family unicast
peer 10.1.2.2 route-policy for_isp1_in import //Apply import policy
named for_isp1_in to the routes learned from 10.1.2.2 and use for_isp1_in to modify
the PrefVal value.
peer 10.1.3.2 route-policy for_isp2_in import //Apply import policy
named for_isp2_in to the routes learned from 10.1.3.2 and use for_isp2_in to modify
the PrefVal value.
#
route-policy for_isp1_in permit node 10 //Define the first node
of for_isp1_in and set the PrefVal value of the route 10.11.0.0/16 to 80.
if-match ip-prefix for_isp1
apply preferred-value 80
#
route-policy for_isp1_in permit node 20 //Define the second node
of for_isp1_in and allow for_isp1_in to permit all routes.
#
route-policy for_isp2_in permit node 10 //Define the first node
of for_isp2_in and set the PrefVal value of the route 10.22.0.0/16 to 120.
if-match ip-prefix for_isp2
apply preferred-value 120
#
route-policy for_isp2_in permit node 20 //Define the second node
of for_isp2_in and allow for_isp2_in to permit all routes.
#
ip ip-prefix for_isp1 index 10 permit 10.11.0.0 16 //Configure an IP prefix
list to match the route 10.11.0.0/16.
ip ip-prefix for_isp2 index 10 permit 10.22.0.0 16 //Configure an IP prefix
list to match the route 10.22.0.0/16.
#

Run the display bgp routing-table [ ip-address ] command to check the configurations.

# Display the routing table of Router A.


[Router A] display bgp routing-table

BGP Local router ID is 10.1.2.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: 4


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 10.11.0.0/16 10.1.2.2 80 300 100?

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 27


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

* 10.1.3.2 0 200?
*> 10.22.0.0/16 10.1.3.2 120 200?
* 10.1.2.2 0 300 100?

The preceding command output shows that Router A selects the route 10.11.0.0/16 learned from
ISP1 and the route 10.22.0.0/16 learned from ISP2.

# Display detailed information about the route 10.22.0.0/16 on Router A.


[Router A] display bgp routing-table 10.22.0.0

BGP local router ID : 10.1.2.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.22.0.0/16:
From: 10.1.3.2 (10.1.3.2)
Route Duration: 00h14m14s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 10.1.3.2
Qos information : 0x0
AS-path 200, origin incomplete, pref-val 120, valid, external, best, select,
active, pre 255
Advertised to such 2 peers:
10.1.3.2
10.1.2.2
BGP routing table entry information of 10.22.0.0/16:
From: 10.1.2.2 (10.1.2.2)
Route Duration: 00h07m54s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path 300 100, origin incomplete, pref-val 0, valid, external, pre 255, not
preferred for PreVal
Not advertised to any peer yet

The preceding command output shows that two routes 10.22.0.0/16 are available in the BGP
routing table of Router A and that the route with the next hop address 10.1.3.2 is selected because
its PrefVal (120) is greater than the PrefVal (0) of the route with next hop address 10.1.2.2. The
PrefVal value is sufficient enough to determine the optimal route, and therefore, Router A does
not compare other route attributes.

The preceding examples show that PrefVal values can be configured as required to control the
traffic forwarding path.

4.3 Local_Pref
BGP prefers the route with the highest Local_Pref during BGP route selection.

The Local_Pref attribute is used to determine the optimal route when traffic leaves an AS. The
Local_Pref attribute is available only to IBGP peers and is not advertised to other ASs.

Table 4-5 lists two methods to modify the Local_Pref value.

Table 4-5 Methods to modify the Local_Pref value

Method Usage Scenario

Run the default local-preference command. This method sets a default Local_Pref for the
routes that the local device advertises to IBGP
peers.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 28


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Method Usage Scenario

Configure an import or export policy and run This method sets different Local_Pref values
the apply local-preference command to for different routes that the local device
configure an apply clause for the policy. advertises to IBGP peers.
NOTE
If both the methods are used, the method with the
import policy takes effect if routes match the
conditions specified in the apply local-
preference command and the policy.

The following example shows how the Local_Pref value is used during route selection. In Figure
4-3, both ISP1 and ISP2 advertise the routes 10.11.0.0/16 and 10.22.0.0/16 to AS 65001.

Figure 4-3 Local_Pref application networking

Internet

10.11.0.0/16
10.22.0.0/16

ISP1 ISP2
AS 100 AS 200

10.1.1.1/30 10.1.2.1/30

EBGP EBGP
Client Network
AS 65001
10.1.1.2/30 10.1.2.2/30
10.1.3.1/30
RouterA RouterB
IBGP 10.1.3.2/30
10.1.4.1/30 10.1.5.1/30
IBGP IBGP

10.1.4.2/30 10.1.5.2/30

RouterC

Scenario 1: When no Local_Pref value is configured on Router A and Router B, check the BGP
routing tables of Router A and Router B.
[Router A] display bgp routing-table

BGP Local router ID is 192.168.2.3


Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 29


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

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

Total Number of Routes: 6


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 10.1.1.0/30 0.0.0.0 0 0 i


*>i 10.1.2.0/30 10.1.3.2 0 100 0 i
*> 10.11.0.0/16 10.1.1.1 0 100 10i
* i 10.1.2.1 100 0 200 10i
*> 10.22.0.0/16 10.1.1.1 0 100 10i
* i 10.1.2.1 100 0 200 10i

The BGP routing table of Router A shows that Router A receives the routes 10.11.0.0/16 and
10.22.0.0/16 from ISP1 and Router B. Check the information about the route 10.11.0.0/16 on
Router A.
[Router A] display bgp routing-table 10.11.0.0

BGP local router ID : 192.168.2.3


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.1.1 (192.168.2.5)
Route Duration: 04h41m03s
Direct Out-interface: GigabitEthernet1/0/1
Original nexthop: 10.1.1.1
Qos information : 0x0
AS-path 100 10, origin igp, pref-val 0, valid, external, best, select, active, pre
255
Advertised to such 2 peers:
10.1.3.2
10.1.4.2
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.3.2 (192.168.2.2)
Route Duration: 01h42m40s
Relay IP Nexthop: 10.1.3.2
Relay IP Out-Interface: GigabitEthernet1/0/3
Original nexthop: 10.1.2.1
Qos information : 0x0
AS-path 200 10, origin igp, localpref 100, pref-val 0, valid, internal, pre 255,
not preferred for peer type
Not advertised to any peer yet

The preceding command output shows that the route learned from ISP1 is selected as the optimal
route because it is an EBGP route and the route learned from Router B is an IBGP route. Table
4-6 shows the route attribute comparison of the routes 10.11.0.0/16 learned from ISP1 and Router
B.

Table 4-6 Route attribute comparison of the routes 10.11.0.0/16 learned from ISP1 and Router
B

Route Attribute Route Learned Route Learned Comparison


from ISP1 from Router B

PrefVal 0 0 The same.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 30


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Route Attribute Route Learned Route Learned Comparison


from ISP1 from Router B

Local_Pref - 100 The same.


NOTE
If a route does not
carry Local_Pref, the
default value 100
takes effect.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path 100 10 200 10 The same length.

Origin IGP IGP The same.

MED - - The same.

Peer type EBGP IBGP Route 10.11.0.0/16


learned from ISP1 is
optimal.

The route selection process on Router B is the same as that on Router A. Then, Router A and
Router B advertise the optimal routes to Router C. Check the routing table of Router C.
[Router C] display bgp routing-table

Total Number of Routes: 6

BGP Local router ID is 192.168.2.1


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

Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 10.1.1.0/30 10.1.4.1 0 100 0 i


*>i 10.1.2.0/30 10.1.5.1 0 100 0 i
*>i 10.11.0.0/16 10.1.2.1 100 0 200 10i
* i 10.1.1.1 100 0 100 10i
*>i 10.22.0.0/16 10.1.2.1 100 0 200 10i
* i 10.1.1.1 100 0 100 10i

The preceding command output shows that Router C selects the routes advertised by Router B.
Check the reason why the routes learned from Router A are not selected on Router C. The route
10.11.0.0/16 is used as an example.
[Router C] display bgp routing-table 10.11.0.0

BGP local router ID : 192.168.2.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.5.1 (192.168.2.2)
Route Duration: 00h12m46s
Relay IP Nexthop: 10.1.5.1
Relay IP Out-Interface: GigabitEthernet1/0/1

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 31


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Original nexthop: 10.1.2.1


Qos information : 0x0
AS-path 200 10, origin igp, localpref 100, pref-val 0, valid, internal, best,
select, active, pre 255
Not advertised to any peer yet

BGP routing table entry information of 10.11.0.0/16:


From: 10.1.4.1 (192.168.2.3)
Route Duration: 00h17m30s
Relay IP Nexthop: 10.1.4.1
Relay IP Out-Interface: GigabitEthernet1/0/0
Original nexthop: 10.1.1.1
Qos information : 0x0
AS-path 100 10, origin igp, localpref 100, pref-val 0, valid, internal, pre 255,
not preferred for router ID
Not advertised to any peer yet

The preceding command output shows that Router C selects the route 10.11.0.0/16 learned from
Router B because the router ID (192.168.2.2) of Router B is smaller than that (192.168.2.3) of
Router A. Table 4-7 shows the route attribute comparison of the routes 10.11.0.0/16 learned
from Router A and Router B.

Table 4-7 Route attribute comparison of the routes 10.11.0.0/16 learned from Router A and
Router B

Route Attribute Route Learned Route Learned Comparison


from Router A from Router B

PrefVal 0 0 The same.

Local_Pref 100 100 The same.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path 100 10 200 10 The same length.

Origin IGP IGP The same.

MED - - The same.

Peer type IBGP IBGP The same.

IGP cost - - The same.

Cluster_List - - The same length.

Router ID 192.168.2.3 192.168.2.2 Route 10.11.0.0/16


learned from Router
B is optimal.

Scenario 2: The administrator of AS 65001 requires that ISP1 be active and ISP2 be backup for
the traffic to 10.11.0.0/16 and 10.22.0.0/16.

To meet the preceding requirements, run the default local-preference command on Router A
to increase the Local_Pref values of the routes learned from Router A. This configuration ensures

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 32


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

that the routes learned from ISP1 are selected as the optimal routes. Detailed configurations are
as follows:
#
bgp 65001
#
ipv4-family unicast
default local-preference 120 //Set the Local_Pref of the routes
to be advertised to 120.
#

Run the display bgp routing-table [ ip-address ] command to check the configurations.

# Display the routing table of Router A.


[Router A] display bgp routing-table

BGP Local router ID is 192.168.2.3


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

*> 10.1.1.0/30 0.0.0.0 0 0 i


*>i 10.1.2.0/30 10.1.3.2 0 100 0 i
*> 10.11.0.0/16 10.1.1.1 0 100 10i
*> 10.22.0.0/16 10.1.1.1 0 100 10i

The preceding command output shows that Router A selects the routes learned from ISP1.

# Display the routing table of Router B.


[Router B] display bgp routing-table

BGP Local router ID is 192.168.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

*>i 10.1.1.0/30 10.1.3.1 0 120 0 i


*> 10.1.2.0/30 0.0.0.0 0 0 i
*>i 10.11.0.0/16 10.1.1.1 120 0 100 10i
* 10.1.2.1 0 200 10i
*>i 10.22.0.0/16 10.1.1.1 120 0 100 10i
* 10.1.2.1 0 200 10i

The preceding command output shows that Router B selects the routes learned from Router A.
Router B does not advertise the routes learned from ISP2 to its IBGP peers because those routes
are not selected.

# Display detailed information about the route 10.11.0.0/16 or 10.22.0.0/16 on Router B. The
route 10.11.0.0/16 is used as an example.
[Router B] display bgp routing-table 10.11.0.0

BGP local router ID : 192.168.2.2


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.11.0.0/16:

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 33


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

From: 10.1.3.1 (192.168.2.3)


Route Duration: 00h22m16s
Relay IP Nexthop: 10.1.3.1
Relay IP Out-Interface: GigabitEthernet1/0/4
Original nexthop: 10.1.1.1
Qos information : 0x0
AS-path 100 10, origin igp, localpref 120, pref-val 0, valid, internal, best,
select, active, pre 255
Advertised to such 1 peers:
10.1.2.1
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.2.1 (192.168.2.4)
Route Duration: 00h22m23s
Direct Out-interface: GigabitEthernet1/0/0
Original nexthop: 10.1.2.1
Qos information : 0x0
AS-path 200 10, origin igp, pref-val 0, valid, external, pre 255, not preferred
for Local_Pref
Not advertised to any peer yet

The preceding command output shows that the Local_Pref value of the route learned from Router
A is greater than that of the route learned from ISP2 and that the route learned from Router A
is selected as the optimal route. Table 4-8 shows the route attribute comparison of the routes
10.11.0.0/16 learned from Router A and ISP2.

Table 4-8 Route attribute comparison of the routes 10.11.0.0/16 learned from Router A and
ISP2

Route Attribute Route Learned Route Learned Comparison


from Router A from ISP2

PrefVal 0 0 The same.

Local_Pref 120 - Route 10.11.0.0/16


learned from Router
A is optimal.
NOTE
If a route does not
carry Local_Pref, the
default value 100
takes effect.

# Display the routing table of Router C.


[Router C] display bgp routing-table

Total Number of Routes: 4

BGP Local router ID is 192.168.2.1


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

Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 10.1.1.0/30 10.1.4.1 0 120 0 i


*>i 10.1.2.0/30 10.1.5.1 0 100 0 i
*>i 10.11.0.0/16 10.1.1.1 120 0 100 10i
*>i 10.22.0.0/16 10.1.1.1 120 0 100 10i

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 34


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Router C selects the routes advertised by ISP1 because Router B did not advertise the routes
learned from ISP2 to Router C.

Scenario 3: The requirements of the administrator of AS 65001 are as follows:

l ISP1 is active and ISP2 is backup for the traffic to 10.11.0.0/16.


l ISP2 is active and ISP1 is backup for the traffic to 10.22.0.0/16.

To meet the preceding requirements, ensure that AS 65001 selects the route 10.11.0.0/16 learned
from Router A and the route 10.22.0.0/16 learned from Router B. Detailed configurations are
as follows:

Figure 4-4 Local_Pref-based BGP route selection networking (1)

Internet

10.11.0.0/16
10.22.0.0/16

ISP1 ISP2
AS 100 AS 200

Set Local_Pref: EBGP EBGP Set Local_Pref:


120 for 10.11.0.0/16 Client Network 200 for 10.22.0.0/16
80 for 10.22.0.0/16 AS 65001 60 for 10.11.0.0/16

To: 11.0.0.0/8
RouterA RouterB
To: 22.0.0.0/8
To: 11.0.0.0/8 IBGP To: 22.0.0.0/8

IBGP IBGP

RouterC

Best route

In this situation, different Local_Pref values are required for the routes learned from the same
ISP. To configure different Local_Pref values for the routes learned from the same ISP, configure
route-policies. Detailed configurations are as follows:
l Configurations on Router A
#
bgp 65001
#
ipv4-family unicast
peer 10.1.1.1 route-policy rp1 import //Apply import policy
named rp1 to the routes learned from 10.1.1.1 and use rp1 to modify the
Local_Pref.
#
route-policy rp1 permit node 10 //Define the first
node of rp1 and set the Local_Pref value of the route 10.11.0.0/16 to 80.
if-match ip-prefix reducepref
apply local-preference 80
#
route-policy rp1 permit node 20 //Define the second
node of rp1 and set the Local_Pref value of the route 10.22.0.0/16 to 120.
if-match ip-prefix addpref

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 35


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

apply local-preference 120


#
route-policy rp1 permit node 30 //Define the third
node of rp1 and allow rp1 to permit all routes.
#
ip ip-prefix addpref index 10 permit 10.11.0.0 16 //Configure an IP
prefix list to match the route 10.11.0.0/16.
ip ip-prefix reducepref index 10 permit 10.22.0.0 16 //Configure an IP
prefix list to match the route 10.22.0.0/16.
#

l Configurations on Router B
bgp 65001
#
ipv4-family unicast
peer 10.1.2.1 route-policy rp2 import //Apply import policy
named rp2 to the routes learned from 10.1.1.1 and use rp2 to modify the
Local_Pref.
#
route-policy rp2 permit node 10 //Define the first
node of rp2 and set the Local_Pref value of the route 10.22.0.0/16 to 200.
if-match ip-prefix addpref
apply local-preference 200
#
route-policy rp2 permit node 20 //Define the second
node of rp2 and set the Local_Pref value of the route 10.11.0.0/16 to 60.
if-match ip-prefix reducepref
apply local-preference 60
#
route-policy rp2 permit node 30 //Define the third
node of rp2 and allow rp2 to permit all routes.
#
ip ip-prefix addpref index 10 permit 10.22.0.0 16 //Configure an IP
prefix list to match the route 10.22.0.0/16.
ip ip-prefix reducepref index 10 permit 10.11.0.0 16 //Configure an IP
prefix list to match the route 10.11.0.0/16.
#

Run the display bgp routing-table [ ip-address ] command to check the configurations.
# Display the routing table of Router A.
[Router A] display bgp routing-table

BGP Local router ID is 192.168.2.3


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

*> 10.1.1.0/30 0.0.0.0 0 0 i


*>i 10.1.2.0/30 10.1.3.2 0 100 0 i
*> 10.11.0.0/16 10.1.1.1 120 0 100 10i
*>i 10.22.0.0/16 10.1.2.1 200 0 200 10i
* 10.1.1.1 80 0 100 10i

# Display detailed information about the route 10.22.0.0/16 on Router A.


[Router A] display bgp routing-table 10.22.0.0

BGP local router ID : 192.168.2.3


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.22.0.0/16:
From: 10.1.3.2 (192.168.2.2)

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 36


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Route Duration: 00h20m12s


Relay IP Nexthop: 10.1.3.2
Relay IP Out-Interface: GigabitEthernet1/0/3
Original nexthop: 10.1.2.1
Qos information : 0x0
AS-path 200 10, origin igp, localpref 200, pref-val 0, valid, internal, best,
select, active, pre 255
Advertised to such 1 peers:
10.1.1.1
BGP routing table entry information of 10.22.0.0/16:
From: 10.1.1.1 (192.168.2.5)
Route Duration: 00h19m40s
Direct Out-interface: GigabitEthernet1/0/1
Original nexthop: 10.1.1.1
Qos information : 0x0
AS-path 100 10, origin igp, localpref 80, pref-val 0, valid, external, pre 255,
not preferred for Local_Pref
Not advertised to any peer yet

The preceding command output shows that two routes 10.22.0.0/16 are available in the BGP
routing table of Router A and that the route with next hop address 10.1.2.1 is selected because
its Local_Pref (200) is greater than the Local_Pref (80) of the route with next hop address
10.1.1.1.
Table 4-9 shows the route attribute comparison of the routes 10.22.0.0/16 learned from ISP1
and Router B.

Table 4-9 Route attribute comparison of the routes 10.22.0.0/16 learned from ISP1 and Router
B.

Route Attribute Route Learned Route Learned Comparison


from ISP1 from Router B

PrefVal 0 0 The same.

Local_Pref 200 80 Route 10.22.0.0/16


learned from ISP1 is
optimal.

The route with next hop address 10.1.1.1 is not optimal, and therefore, it is not advertised to
Router B and Router C. In addition, the route 10.11.0.0/16 with next hop address 10.1.2.1 is not
optimal on Router B, and therefore, Router B does not advertise this route to Router A and Router
C. As a result, only one route 10.11.0.0/16 with next hop address 10.1.1.1 is available in the
BGP routing table of Router A.
# Display the routing table of Router B.
[Router B] display bgp routing-table

BGP Local router ID is 192.168.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 10.1.1.0/30 10.1.3.1 0 100 0 i

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 37


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

*> 10.1.2.0/30 0.0.0.0 0 0 i


*>i 10.11.0.0/16 10.1.1.1 120 0 100 10i
* 10.1.2.1 60 0 200 10i
*> 10.22.0.0/16 10.1.2.1 200 0 200 10i

# Display detailed information about the route 10.11.0.0/16 on Router B.


[Router B] display bgp routing-table 10.11.0.0

BGP local router ID : 192.168.2.2


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.3.1 (192.168.2.3)
Route Duration: 00h40m28s
Relay IP Nexthop: 10.1.3.1
Relay IP Out-Interface: GigabitEthernet1/0/4
Original nexthop: 10.1.1.1
Qos information : 0x0
AS-path 100 10, origin igp, localpref 120, pref-val 0, valid, internal, best,
select, active, pre 255
Advertised to such 1 peers:
10.1.2.1
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.2.1 (192.168.2.4)
Route Duration: 00h41m00s
Direct Out-interface: GigabitEthernet1/0/0
Original nexthop: 10.1.2.1
Qos information : 0x0
AS-path 200 10, origin igp, localpref 60, pref-val 0, valid, external, pre 255,
not preferred for Local_Pref
Not advertised to any peer yet

The preceding command output shows that two routes 10.11.0.0/16 are available in the BGP
routing table of Router B and that the route with next hop address 10.1.1.1 is selected because
its Local_Pref (120) is greater than the Local_Pref (60) of the route with next hop address
10.1.2.1. The route with next hop address 10.1.2.1 is not advertised to Router A and Router C
because it is not optimal.

# Display the routing table of Router C.


[Router C] display bgp routing-table

Total Number of Routes: 4

BGP Local router ID is 192.168.2.1


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

Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 10.1.1.0/30 10.1.4.1 0 100 0 i


*>i 10.1.2.0/30 10.1.5.1 0 100 0 i
*>i 10.11.0.0/16 10.1.1.1 120 0 100 10i
*>i 10.22.0.0/16 10.1.2.1 200 0 200 10i

The preceding command output shows that the next hop address of the route 10.11.0.0/16 is
10.1.1.1 and that the next hop address of the route 10.22.0.0/16 is 10.1.2.1.

Scenario 4: The requirements of the administrator of AS 65001 are as follows:


l ISP1 is active and ISP2 is backup for the traffic from Router A and Router C to 10.11.0.0/16
and 10.22.0.0/16.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 38


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

l ISP2 is active and ISP1 is backup for the traffic from Router B to 10.11.0.0/16 and
10.22.0.0/16.

To meet the preceding requirements, ensure that Router A and Router C select the routes learned
from ISP1. Detailed configurations are as follows:

Figure 4-5 Local_Pref-based BGP route selection networking (2)

Internet

10.11.0.0/16
10.22.0.0/16

ISP1 ISP2
AS 100 AS 200

To: To:
10.11.0.0/16 EBGP EBGP
10.11.0.0/16
10.22.0.0/16 10.22.0.0/16
Client Network
AS 65001
IBGP
RouterA RouterB
To:
11.0.0.0/8
22.0.0.0/8
IBGP IBGP

RouterC

Best route

You can perform either of the following operations:


l Configure an export policy on Router A to modify the Local_Pref of the routes to be
advertised to Router C.
l Configure an import policy on Router C to modify the Local_Pref of the routes learned
from Router A.
The configurations on Router A are used as an example. Detailed configurations are as follows:
bgp 65001
#
ipv4-family unicast
default local-preference 120 //Set the Local_Pref of the routes
to be advertised to 120.

Run the display bgp routing-table [ ip-address ] command to check the configurations.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 39


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

# Display the routing table of Router A.


[Router A] display bgp routing-table

BGP Local router ID is 192.168.2.3


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

*> 10.1.1.0/30 0.0.0.0 0 0 i


*>i 10.1.2.0/30 10.1.3.2 0 100 0 i
*> 10.11.0.0/16 10.1.1.1 0 100 10i
* i 10.1.2.1 100 0 200 10i
*> 10.22.0.0/16 10.1.1.1 0 100 10i
* i 10.1.2.1 100 0 200 10i

The preceding command output shows that Router B selects the routes learned from ISP1.
# Display the routing table of Router B.
[Router B] display bgp routing-table

BGP Local router ID is 192.168.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

*>i 10.1.1.0/30 10.1.3.1 0 100 0 i


*> 10.1.2.0/30 0.0.0.0 0 0 i
*> 10.11.0.0/16 10.1.2.1 0 200 10i
* i 10.1.1.1 100 0 100 10i
*> 10.22.0.0/16 10.1.2.1 0 200 10i
* i 10.1.1.1 100 0 100 10i

The preceding command output shows that Router B selects the routes learned from ISP2.
# Display the routing table of Router C.
[Router C] display bgp routing-table

Total Number of Routes: 6

BGP Local router ID is 192.168.2.1


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

Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 10.1.1.0/30 10.1.4.1 0 120 0 i


*>i 10.1.2.0/30 10.1.5.1 0 100 0 i
*>i 10.11.0.0/16 10.1.1.1 120 0 100 10i
* i 10.1.2.1 100 0 200 10i
*>i 10.22.0.0/16 10.1.1.1 120 0 100 10i
* i 10.1.2.1 100 0 200 10i

The preceding command output shows that Router C selects the routes learned from ISP1.
# Display detailed information about the route 10.11.0.0/16 or 10.22.0.0/16 on Router C. The
route 10.11.0.0/16 is used as an example.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 40


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

[Router C] display bgp routing-table 10.11.0.0

BGP local router ID : 192.168.2.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.11.0.0/16:
From: 10.1.4.1 (192.168.2.3)
Route Duration: 00h06m26s
Relay IP Nexthop: 10.1.4.1
Relay IP Out-Interface: GigabitEthernet1/0/0
Original nexthop: 10.1.1.1
Qos information : 0x0
AS-path 100 10, origin igp, localpref 120, pref-val 0, valid, internal, best,
select, active, pre 255
Not advertised to any peer yet

BGP routing table entry information of 10.11.0.0/16:


From: 10.1.5.1 (192.168.2.2)
Route Duration: 00h08m05s
Relay IP Nexthop: 10.1.5.1
Relay IP Out-Interface: GigabitEthernet1/0/1
Original nexthop: 10.1.2.1
Qos information : 0x0
AS-path 200 10, origin igp, localpref 100, pref-val 0, valid, internal, pre 255,
not preferred for Local_Pref
Not advertised to any peer yet

The preceding command output shows that Router C selects the routes learned from ISP1
because the Local_Pref of the routes learned from ISP1 is greater than that of the route learned
from ISP2.

The preceding examples show that the modification of the Local_Pref values affects not only
BGP route advertisement but also BGP route selection with an AS. We can configure Local_Pref
values as required to control the forwarding path of the traffic that leaves an AS.

4.4 Route Type


BGP prefers locally imported routes to the routes learned from peers during BGP route selection.

BGP routes can be locally imported or learned from peers. The locally imported routes take
precedence over the routes learned from peers during BGP route selection. It is unusual for
locally imported routes and the routes learned from peers to carry the same destination IP address
and coexist in the routing table. Generally, locally imported routes can be the routes imported
using the network or import-route command and the automatically and manually summarized
routes. Precedences of these routes are described as follows:

1. Summarized routes take precedence over non-summarized routes.


2. Summarized routes that are manually generated using the aggregate command take
precedence over summarized routes that are automatically generated based on the
summary automatic command settings.
3. The routes imported using the network command take precedence over the routes imported
using the import-route command.

In Figure 4-6, Router A and Router B are EBGP peers, and Router B, Router C, and Router D
are IBGP peers.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 41


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Figure 4-6 Networking

AS 100 AS 65001
Router A Router B Router D
10.1.1.1/30 10.1.1.2/30 10.1.3.1/30
IBGP 10.1.3.2/30
10.1.2.1/30 10.1.4.1/30

IBGP IBGP
Router C
10.1.2.2/30 10.1.4.2/30

The configurations on Router C are as follows:


#
bgp 65001
#
ipv4-family unicast
network 10.1.2.0 255.255.255.252 //Advertise the route
10.1.2.0/30.
network 10.1.3.0 255.255.255.252 //Advertise the route
10.1.3.0/30.
import-route direct //Import direct routes.
#

The configurations on Router D are as follows:


#
bgp 65001
#
ipv4-family unicast
network 10.1.3.0 255.255.255.252 //Advertise the route
10.1.3.0/30.
network 10.1.4.0 255.255.255.252 //Advertise the route
10.1.4.0/30.
import-route direct //Import direct routes.
#

Run the display bgp routing-table [ ip-address ] command to check the configurations.

# Display the routing table of Router D.


[Router D] display bgp routing-table

BGP Local router ID is 10.1.3.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: 10


Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 10.1.2.0/30 10.1.4.2 0 100 0 i


*> 10.1.3.0/30 0.0.0.0 0 0 i
* 0.0.0.0 0 0 ?
*> 10.1.3.2/32 0.0.0.0 0 0 ?
*> 10.1.4.0/30 0.0.0.0 0 0 i
* 0.0.0.0 0 0 ?
i 10.1.4.2 0 100 0 ?
*> 10.1.4.1/32 0.0.0.0 0 0 ?
*> 127.0.0.0 0.0.0.0 0 0 ?
*> 127.0.0.1/32 0.0.0.0 0 0 ?

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 42


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

The preceding command output shows that three routes 10.1.4.0/30 are available in the routing
table. The route with the next hop address 10.1.4.2 is learned from a peer (Router C). Therefore,
BGP first excludes this route from route selection.
[Router D] display bgp routing-table 10.1.4.0 30

BGP local router ID : 10.1.3.2


Local AS number : 65001
Paths: 3 available, 1 best, 1 select
BGP routing table entry information of 10.1.4.0/30:
Network route.
From: 0.0.0.0 (0.0.0.0)
Route Duration: 00h03m51s
Direct Out-interface: GigabitEthernet0/0/4
Original nexthop: 10.1.4.1
Qos information : 0x0
AS-path Nil, origin igp, MED 0, pref-val 0, valid, local, best, select, pre 0
Advertised to such 2 peers:
10.1.3.1
10.1.4.2
BGP routing table entry information of 10.1.4.0/30:
Imported route.
From: 0.0.0.0 (0.0.0.0)
Route Duration: 00h04m10s
Direct Out-interface: GigabitEthernet0/0/4
Original nexthop: 10.1.4.1
Qos information : 0x0
AS-path Nil, origin incomplete, MED 0, pref-val 0, valid, local, pre 0, not
preferred for route type
Not advertised to any peer yet

BGP routing table entry information of 10.1.4.0/30:


From: 10.1.4.2 (10.1.2.2)
Route Duration: 00h02m24s
Relay IP Nexthop: 0.0.0.0
Relay IP Out-Interface: GigabitEthernet0/0/4
Original nexthop: 10.1.4.2
Qos information : 0x0
AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, internal, pre
255
Not advertised to any peer yet

The preceding command output shows that the route imported using the network command is
selected as the optimal route.

The configurations on Router B are as follows:


bgp 65001
#
ipv4-family unicast
summary automatic
aggregate 10.0.0.0 255.0.0.0
import-route direct
#

Run the display bgp routing-table [ ip-address ] command to check the configurations.

# Display the routing table of Router B.


[Router B] display bgp routing-table

BGP Local router ID is 10.1.1.2


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

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 43


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Total Number of Routes: 14


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 10.0.0.0 127.0.0.1 0 ?


* 127.0.0.1 0 ?
s> 10.1.1.0/30 0.0.0.0 0 0 ?
*> 10.1.1.2/32 0.0.0.0 0 0 ?
s> 10.1.2.0/30 0.0.0.0 0 0 ?
i 10.1.2.2 0 100 0 i
*> 10.1.2.1/32 0.0.0.0 0 0 ?
s> 10.1.3.0/30 0.0.0.0 0 0 ?
i 10.1.3.2 0 100 0 i
*> 10.1.3.1/32 0.0.0.0 0 0 ?
*>i 10.1.4.0/30 10.1.3.2 0 100 0 i
* i 10.1.2.2 0 100 0 ?
*> 127.0.0.0 0.0.0.0 0 0 ?
*> 127.0.0.1/32 0.0.0.0 0 0 ?

The preceding command output shows that two summarized routes 10.0.0.0 are available in the
routing table.
[Router B] display bgp routing-table 10.0.0.0

BGP local router ID : 10.1.1.2


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.0.0.0/8:
Aggregated route.
Route Duration: 00h17m04s
Direct Out-interface: NULL0
Original nexthop: 127.0.0.1
Qos information : 0x0
AS-path Nil, origin incomplete, pref-val 0, valid, local, best, select, active,
pre 255
Aggregator: AS 65001, Aggregator ID 10.1.1.2
Advertised to such 3 peers:
10.1.1.1
10.1.3.2
10.1.2.2
BGP routing table entry information of 10.0.0.0/8:
Summary automatic route
Route Duration: 00h17m04s
Direct Out-interface: NULL0
Original nexthop: 127.0.0.1
Qos information : 0x0
AS-path Nil, origin incomplete, pref-val 0, valid, local, pre 255, not preferred
for route type
Aggregator: AS 65001, Aggregator ID 10.1.1.2
Not advertised to any peer yet

The preceding command output shows that the route generated using the aggregate command
is selected as the optimal route.

4.5 AIGP
BGP prefers the route with the smallest AIGP value during BGP route selection.

The Accumulated Interior Gateway Protocol Metric (AIGP) attribute is an optional non-
transitive Border Gateway Protocol (BGP) path attribute. After the AIGP attribute is configured
in an AIGP administrative domain, BGP selects paths based on costs in the same manner as an
IGP, and all devices in the domain forward data along the optimal routes. During BGP route
selection, the AIGP attribute is used as follows:

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 44


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

l The priority of a route that carries the AIGP attribute is higher than the priority of a route
that does not carry the AIGP attribute.
l If two BGP routes both carry the AIGP attribute, the device selects the BGP route whose
AIGP value plus the cost of the IGP route to which the BGP route is iterated is smaller.
The AIGP attribute can be added to routes only through route-policies. You can configure an
apply clause for a route-policy using the apply aigp { cost | inherit-cost } command to modify
the AIGP value during BGP route import, acceptance, or advertisement. If no AIGP value is
configured, the IGP routes imported by BGP do not carry the AIGP attribute.
In Figure 4-7, OSPF runs in AS 65002, an EBGP peer relationship is established between Router
A and Router E and between Router B and Router E. Router A and Router B are configured to
import OSPF routes in AS 65002 and advertise the routes to AS 65001.

Figure 4-7 AIGP application networking

AS 65001

Router E

10.1.1.1/30 10.1.3.1/30

EBGP EBGP
10.1.1.2/30 10.1.3.2/30

Router A Router B
10.1.2.1/30 10.1.5.1/30
AS 65002

10.1.2.2/30 10.1.5.2/30
10.1.4.1/30
Router C 10.1.4.2/30 Router D

Run the display bgp routing-table [ ip-address ] command on Router E to check the
configurations. The route 10.1.4.0/30 is used in this example.
# Display the routing table of Router E.
[Router E] display bgp routing-table

BGP Local router ID is 10.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

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 45


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Network NextHop MED LocPrf PrefVal Path/Ogn

*> 10.1.2.0/30 10.1.1.2 0 0 65002?


* 10.1.3.2 3 0 65002?
*> 10.1.4.0/30 10.1.1.2 2 0 65002?
* 10.1.3.2 2 0 65002?
*> 10.1.5.0/30 10.1.3.2 0 0 65002?
* 10.1.1.2 3 0 65002?
[Router E] display bgp routing-table 10.1.4.0

BGP local router ID : 10.1.1.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.1.4.0/30:
From: 10.1.1.2 (10.1.1.2)
Route Duration: 00h02m29s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 10.1.1.2
Qos information : 0x0
AS-path 65002, origin incomplete, MED 2, pref-val 0, valid, external, best,
select, active, pre 255
Advertised to such 2 peers:
10.1.1.2
10.1.3.2
BGP routing table entry information of 10.1.4.0/30:
From: 10.1.3.2 (10.1.5.1)
Route Duration: 00h03m58s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.3.2
Qos information : 0x0
AS-path 65002, origin incomplete, MED 2, pref-val 0, valid, external, pre 255, not
preferred for router ID
Not advertised to any peer yet

The command output shows that Router E selects the route learned from Router A because the
AIGP attribute has not been configured and the router ID of Router A is smaller than that of
Router B. To change the route selection on Router E, perform the following operations to
configure the AIGP attribute.
Configurations on Router A:
#
bgp 65002
#
ipv4-family unicast
import-route ospf 1 route-policy aigp_policy //Apply route-policy named
aigp_policy to locally imported OSPF routes and use aigp_policy to modify the AIGP
value.
peer 10.1.1.1 aigp //Enable AIGP on the local
device and the peer 10.1.1.1.
#
route-policy aigp_policy permit node 10 //Define the first node of
aigp_policy and set the AIGP value of the route 10.1.4.0/30 to 10.
if-match ip-prefix prefix1
apply aigp 10
#
route-policy aigp_policy permit node 20 //Define the second node of
aigp_policy and allow aigp_policy to permit all routes.
#
ip ip-prefix prefix1 index 10 permit 10.1.4.0 30 //Configure IP prefix list
named prefix1 to match the route 10.1.4.0/30.
#

Configurations on Router B:
bgp 65002
peer 10.1.3.1 as-number 65001

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 46


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

#
ipv4-family unicast
import-route ospf 1 route-policy aigp_policy1 //Apply route-policy named
aigp_policy1 to locally imported OSPF routes and use aigp_policy1 to modify the
AIGP value.
peer 10.1.3.1 aigp //Enable AIGP on the local
device and the peer 10.1.3.1.
#
route-policy aigp_policy1 permit node 10 //Define the first node of
aigp_policy1 and set the AIGP value of the route 10.1.4.0/30 to 5.
if-match ip-prefix prefix2
apply aigp 5
#
route-policy aigp_policy1 permit node 20 //Define the second node of
aigp_policy1 and allow aigp_policy1 to permit all routes.
#
ip ip-prefix prefix2 index 10 permit 10.1.4.0 30 //Configure IP prefix list
named prefix2 to match the route 10.1.4.0/30.
#

Configurations on Router E:
#
bgp 65001
#
ipv4-family unicast
peer 10.1.1.2 aigp //Enable AIGP on the local
device and the peer 10.1.1.2.
peer 10.1.3.2 aigp //Enable AIGP on the local
device and the peer 10.1.3.2.
#

Run the display bgp routing-table [ ip-address ] command on Router E to check the
configurations.

# Display the routing table of Router E.


[Router E] display bgp routing-table

BGP Local router ID is 10.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

*> 10.1.2.0/30 10.1.1.2 0 0 65002?


* 10.1.3.2 3 0 65002?
*> 10.1.4.0/30 10.1.3.2 2 0 65002?
* 10.1.1.2 2 0 65002?
*> 10.1.5.0/30 10.1.3.2 0 0 65002?
* 10.1.1.2 3 0 65002?
[Router E] display bgp routing-table 10.1.4.0

BGP local router ID : 10.1.1.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.1.4.0/30:
From: 10.1.3.2 (10.1.5.1)
Route Duration: 00h00m14s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.3.2
Qos information : 0x0
AS-path 65002, origin incomplete, MED 2, pref-val 0, valid, external, best,
select, active, pre 255, AIGP 5

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 47


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Advertised to such 2 peers:


10.1.1.2
10.1.3.2
BGP routing table entry information of 10.1.4.0/30:
From: 10.1.1.2 (10.1.1.2)
Route Duration: 01h01m15s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 10.1.1.2
Qos information : 0x0
AS-path 65002, origin incomplete, MED 2, pref-val 0, valid, external, pre 255,
AIGP 10, not preferred for AIGP
Not advertised to any peer yet

The preceding command output shows that Router E selects the route 10.1.4.0/30 learned from
Router B because its AIGP value is smaller than that of the route learned from Router A.

Table 4-10 shows the attribute comparison of the routes 10.1.4.0/30 learned from Router A and
Router B.

Table 4-10 Attribute comparison of the routes 10.1.4.0/30 learned from Router A and Router
B.

Route Attribute Route Learned Route Learned Comparison


from Router A from Router B

PrefVal 0 0 The same.

Local_Pref - - The same.

Route type Learned from a peer Learned from a peer The same.

AIGP 10 5 The same.

4.6 AS_Path
BGP prefers the route with the shortest AS_Path length (the number of included ASs) during
BGP route selection.

Four types of AS_Path attributes are available:

l AS_Sequence: records in reverse order all the ASs through which a route passes from the
local device to the destination.
l AS_Set: records in random order all the ASs through which a route passes from the local
device to the destination. The AS_Set attribute is used in route summarization scenarios.
l AS_Confed_Sequence: records in reverse order all the sub-ASs within a BGP confederation
through which a route passes from the local device to the destination.
l AS_Confed_Set: records in random order all the sub-ASs within a BGP confederation
through which a route passes from the local device to the destination.

Table 4-11 describes the AS_Path-based route selection rules.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 48


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Table 4-11 AS_Path-based route selection rules

Item Description

AS_Set BGP takes an AS_Set as one AS number even if the AS_Set


contains multiple AS numbers.
When the aggregate (BGP) command is configured to
generate a manually summarized route, if as-set is specified
in the command, AS_Set will be carried in the summarized
route. The information in the AS_Set is as follows:
l If the routes used in the summarization carry the same
AS_Sequence, this AS_Sequence is carried in the
summarized route, and the AS_Set of the summarized
route is null.
l If the routes used in the summarization carry different
AS_Sequences, all the AS numbers carried in the
AS_Sequences are included in the AS_Set of the
summarized route.

AS_Confed_Sequence and BGP ignores AS_Confed_Sequence and AS_Confed_Set


AS_Confed_Set when calculating the AS_Path length.

bestroute as-path-ignore After the command is configured, BGP does not compare
the AS_Path attribute during route selection.

apply as-path The command can be run to configure an apply clause for a
route-policy so that the ASs in the AS_Path of the route that
matches the route-policy are cleared or replaced, or new ASs
are added.
NOTE
The configuration of the apply as-path command may change the
traffic forwarding path, or cause routing loops or route selection
errors. Therefore, exercise caution when configuring the command.

peer public-as-only After the command is configured, BGP deletes private AS


numbers (if any) from the AS_Path attribute before sending
Update packets. Private AS numbers range from 64512 to
65534.

peer fake-as After the command is configured, BGP can use a fake AS
number to set up a BGP peer relationship.
If the local device uses the actual AS number to establish an
EBGP peer relationship with a remote device, the actual AS
number is carried in the AS_Path of the route sent to the
remote device. If the local device uses the fake AS number
to establish the EBGP peer relationship, the fake AS number
is carried in the AS_Path of the route sent to the remote
device.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 49


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Item Description

peer substitute-as If the command is configured and an AS in the AS_Path


carried in the route sent by a PE to the CE of the specified
peer is the same as the AS of the CE, the PE replaces the AS
with the local AS.
NOTE
The peer substitute-as command applies only to PEs in BGP
MPLS IP/VPN scenarios and may cause routing loops if it is
improperly configured. Therefore, exercise caution when using the
command.

During BGP route selection, BGP compares the AS_Path length by calculating the number of
ASs included in the AS_Sequence if AS_Sequence is carried in a route. If both AS_Sequence
and AS_Set are carried in the route, BGP considers the AS_Path length to be the number of ASs
included in the AS_Sequence plus 1.

Deleting Private AS Numbers


As public AS resources are limited, carriers generally use private AS numbers when deploying
VPNs. Private AS numbers, however, must not be advertised to the Internet because they may
cause routing loops. In Figure 4-8, both ISP1 and ISP2 use 65001 as a private AS number.

Figure 4-8 Networking in which a private AS needs to be deleted


On B: peer C public-as-only

ISP1 ISP2
AS 65001 AS 100 AS 200 AS 65001

10.0.0.0/8
Router A Router B Router C Router D
Update Update
10.0.0.0/8 10.0.0.0/8
AS_Path: 65001 AS_Path: 100

In Figure 4-8, Router A advertises the route 10.0.0.0/8 to Router D through ISP1 and ISP2.
After receiving this route, Router D checks its AS_Path. This AS_Path carries AS 65001, which
is the same as the AS of Router D. As a result, Router D discards this route.

To address this problem, run the peer public-as-only command on Router B so that Router B
deletes AS 65001 before adding AS 100 (public AS) to the AS_Path and forwarding the route
to Router C.

In the following situations, after the peer public-as-only command is configured, BGP does not
delete any private AS number from the AS_Path:
l The AS_Path of a route carries the AS number of the remote peer. In this case, deleting
private AS numbers may lead to a routing loop.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 50


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

l The AS_Path carries both public and private AS numbers, which indicates that the route
has passed through the public network. In this case, deleting private AS numbers may lead
to incorrect traffic forwarding.
The preceding limitations also apply to confederation scenarios.

Adding AS Numbers
In Figure 4-9, AS 65005 imports three routes and advertises them to AS 65001 through two
paths.

Figure 4-9 Networking in which new AS numbers are added to the AS_Path

AS 65002
AS 65004

10.1.2.2/30
10.1.1.2/30 10.1.2.1/30 10.1.4.1/30
Router B Router D
10.1.4.2/30
10.1.1.1/30
AS 65005
AS 65001 Router A Router E 172.16.1.0/24
172.16.2.0/24
172.16.3.0/24
10.1.5.2/30
10.1.3.1/30 Router C
10.1.3.2/30 10.1.5.1/30

AS 65003
BGP Update

Run the display bgp routing-table [ ip-address ] command to check the configurations.

# Display the routing table of Router A.


[Router A] display bgp routing-table

BGP Local router ID is 10.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

*> 172.16.1.0/24 10.1.3.2 0 65003 65005?


* 10.1.1.2 0 65002 65004
65005?
*> 172.16.2.0/24 10.1.3.2 0 65003 65005?
* 10.1.1.2 0 65002 65004
65005?
*> 172.16.3.0/24 10.1.3.2 0 65003 65005?
* 10.1.1.2 0 65002 65004
65005?
[Router A] display bgp routing-table 172.16.1.0

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 51


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

BGP local router ID : 10.1.1.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 172.16.1.0/24:
From: 10.1.3.2 (10.1.5.1)
Route Duration: 00h00m56s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.3.2
Qos information : 0x0
AS-path 65003 65005, origin incomplete, pref-val 0, valid, external, best, select,
active, pre 255
Advertised to such 2 peers:
10.1.3.2
10.1.1.2
BGP routing table entry information of 172.16.1.0/24:
From: 10.1.1.2 (10.1.1.2)
Route Duration: 00h34m43s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 10.1.1.2
Qos information : 0x0
AS-path 65002 65004 65005, origin incomplete, pref-val 0, valid, external, pre
255, not preferred for AS-Path
Not advertised to any peer yet

The preceding command output shows that Router A selects the route learned from Router C
because this route has a shorter AS_Path length than that learned from Router B. To enable
Router A to select the route learned from Router B, configure Router B to reduce the AS_Path
length of the route or configure Router C to increase the AS_Path length of the route. In the
following example, Router C is configured to increase the AS_Path length of the route. The
detailed configurations on Router C are as follows:
#
bgp 65003
#
ipv4-family unicast
undo synchronization
peer 10.1.3.1 route-policy add_asn export //Apply export policy named
add_asn to routes to be advertised to 10.1.3.1.
#
route-policy add_asn permit node 10 //Define the first node of
add_asn.
if-match ip-prefix prefix1 //Configure IP prefix list
named prefix1.
apply as-path 65003 65003 65003 additive //Add 65003, 65003, 65003
to the AS_Path of the route that matches prefix1.
#
route-policy add_asn permit node 20 //Define the second node of
add_asn to permit all other routes.
#
ip ip-prefix prefix1 index 10 permit 172.16.1.0 24 //Define the first index of
prefix1 to match the route 172.16.1.0/24.
ip ip-prefix prefix1 index 20 permit 172.16.2.0 24 //Define the second index
of prefix1 to match the route 172.16.2.0/24.
ip ip-prefix prefix1 index 30 permit 172.16.3.0 24 //Define the third index of
prefix1 to match the route 172.16.3.0/24.
#

Run the display bgp routing-table [ ip-address ] command to check the configurations.

# Display the routing table of Router A.


[Router A] display bgp routing-table

BGP Local router ID is 10.1.1.1


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

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 52


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

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

*> 172.16.1.0/24 10.1.1.2 0 65002 65004


65005?
* 10.1.3.2 0 65003 65003
65003 65003 65005?
*> 172.16.2.0/24 10.1.1.2 0 65002 65004
65005?
* 10.1.3.2 0 65003 65003
65003 65003 65005?
*> 172.16.3.0/24 10.1.1.2 0 65002 65004
65005?
* 10.1.3.2 0 65003 65003
65003 65003 65005?
[Router A] display bgp routing-table 172.16.1.0

BGP local router ID : 10.1.1.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 172.16.1.0/24:
From: 10.1.1.2 (10.1.1.2)
Route Duration: 00h33m30s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 10.1.1.2
Qos information : 0x0
AS-path 65002 65004 65005, origin incomplete, pref-val 0, valid, external, best,
select, active, pre 255
Advertised to such 2 peers:
10.1.3.2
10.1.1.2
BGP routing table entry information of 172.16.1.0/24:
From: 10.1.3.2 (10.1.5.1)
Route Duration: 00h02m12s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.3.2
Qos information : 0x0
AS-path 65003 65003 65003 65003 65005, origin incomplete, pref-val 0, valid,
external, pre 255, not preferred for AS-Path
Not advertised to any peer yet

The preceding command output shows that the AS_Path length of the route learned from Router
B is shorter than that of the route learned from Router C and that the route learned from Router
B is selected as the optimal route. Table 4-12 shows the attribute comparison of the routes
172.16.1.0 learned from Router B and Router C.

Table 4-12 Attribute comparison of the routes 172.16.1.0 learned from Router B and Router C

Route Attribute Route Learned Route Learned Comparison


from Router B from Router C

PrefVal 0 0 The same.

Local_Pref - - The same.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 53


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Route Attribute Route Learned Route Learned Comparison


from Router B from Router C

AS_Path 65002 65004 65005 65003 65003 65003 The route learned
65003 65005 from Router B is
optimal.

AS numbers can be added to the AS_Path as required. However, if an AS number is added to


the AS_Path of a route, the route cannot be received by devices in this AS. Therefore, the local
AS number is added in most cases. For example in Figure 4-9, if Router C adds AS 65001 to
the AS_Path of a route before advertising the route to Router A, Router A will discard the route
upon receipt because the route carries Router A's AS number.

Replacing AS Numbers
When the apply as-path command is configured, if overwrite is specified in the command, the
device will replace the AS numbers in the original AS_Path attribute to achieve the following
goals:
l Hide the actual path information.
l Prevent a route from being discarded by replacing the AS_Path of the route with a shorter
one if the as-path-limit command is configured on the device that receives this route.
l Reduce the AS_Path length.
AS number replacement can also be used for the purpose of load balancing. For example in
Figure 4-9, the apply as-path 65002 65004 65005 overwrite command can be configured on
Router A to replace the AS_Path of the route learned from Router C so that the route has the
same AS_Path as that of the route learned from Router B, and the two routes are used to load-
balance traffic. Detailed configurations on Router A are as follows:
#
bgp 65001
#
ipv4-family unicast
undo synchronization
peer 10.1.3.2 route-policy replace_asn import //Apply export policy named
replace_asn to routes to be advertised to 10.1.3.1.
#
route-policy replace_asn permit node 10 //Define the first node of
replace_asn.
if-match as-path-filter filter1 //Configure AS_Path filter
named filter1.
apply as-path 65002 65004 65005 overwrite //Replace the AS_Path of
the route that matches filter1 with 65002, 65004, 65005.
#
route-policy replace_asn permit node 20 //Define the second node of
replace_asn to permit all other routes.
#
ip as-path-filter filter1 permit ^65003 //Define AS_Path filter
named filter1 to match all the routes learned from AS 65003.
#

Run the display bgp routing-table [ ip-address ] command to check the configurations.
# Display the routing table of Router A.
[Router A] display bgp routing-table

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 54


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

BGP Local router ID is 10.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

*> 172.16.1.0/24 10.1.1.2 0 65002 65004


65005?
* 10.1.3.2 0 65002 65004
65005?
*> 172.16.2.0/24 10.1.1.2 0 65002 65004
65005?
* 10.1.3.2 0 65002 65004
65005?
*> 172.16.3.0/24 10.1.1.2 0 65002 65004
65005?
* 10.1.3.2 0 65002 65004
65005?

The preceding command output shows that the AS_Path of the route received from AS 65003
has been replaced, after which the routes received from AS 65002 and AS 65003 have the same
AS_Path. Run the maximum load-balancing 2 command on Router A to set the maximum
number of routes for load balancing to 2. Then, check the detailed route information. The route
172.16.1.0/24 is used in the following example:
[Router A] display bgp routing-table 172.16.1.0

BGP local router ID : 10.1.1.1


Local AS number : 65001
Paths: 2 available, 1 best, 2 select
BGP routing table entry information of 172.16.1.0/24:
From: 10.1.1.2 (10.1.1.2)
Route Duration: 19h57m51s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 10.1.1.2
Qos information : 0x0
AS-path 65002 65004 65005, origin incomplete, pref-val 0, valid, external, best,
select, active, pre 255
Advertised to such 2 peers:
10.1.1.2
10.1.3.2
BGP routing table entry information of 172.16.1.0/24:
From: 10.1.3.2 (10.1.5.1)
Route Duration: 00h10m21s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.3.2
Qos information : 0x0
AS-path 65002 65004 65005, origin incomplete, pref-val 0, valid, external,
select, active, pre 255, not preferred for router ID
Not advertised to any peer yet

The preceding command output shows that the route learned from Router B is optimal and is
used along with the route learned from Router C (not optimal) for load balancing. Check the
information about the route 172.16.1.0/24 in the IP routing table.
[Router A] display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 9 Routes : 12

Destination/Mask Proto Pre Cost Flags NextHop Interface

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 55


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

10.1.1.0/30 Direct 0 0 D 10.1.1.1


GigabitEthernet0/0/1
10.1.1.1/32 Direct 0 0 D 127.0.0.1
GigabitEthernet0/0/1
10.1.3.0/30 Direct 0 0 D 10.1.3.1
GigabitEthernet0/0/0
10.1.3.1/32 Direct 0 0 D 127.0.0.1
GigabitEthernet0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
172.16.1.0/24 EBGP 255 0 D 10.1.1.2
GigabitEthernet0/0/1
EBGP 255 0 D 10.1.3.2
GigabitEthernet0/0/0
172.16.2.0/24 EBGP 255 0 D 10.1.1.2
GigabitEthernet0/0/1
EBGP 255 0 D 10.1.3.2
GigabitEthernet0/0/0
172.16.3.0/24 EBGP 255 0 D 10.1.1.2
GigabitEthernet0/0/1
EBGP 255 0 D 10.1.3.2 GigabitEthernet0/0/0

The preceding command output shows that BGP has delivered the two routes with the same
route prefix to the IP routing table for load balancing.

Clearing the AS_Path


When the apply as-path command is configured, if none overwrite is specified in the command,
the device clears the AS_Path to hide the actual path information. If the AS_Path is null, BGP
considers its length as 0 during route selection.

4.7 Origin
The Origin attribute indicates how routes become BGP routes.

Three types of Origin attributes are available:


l IGP: indicates that routes are added to the BGP routing table using the network command.
IGP has the highest priority.
l EGP: indicates that routes are learned through the EGP protocol. EGP has the second
highest priority.
NOTE

If the router can receive and send BGP routes with EGP as the Origin, but does not support the EGP
protocol, to set the Origin of routes to EGP, you need to run the apply origin { egp { as-number-
plain | as-number-dot } | igp | incomplete } command to configure an apply clause for a route-policy.
l Incomplete: indicates that routes are added to the BGP routing table using the import-
route command. Incomplete has the lowest priority.

The routes imported using the network command are more specific than those imported using
the import-route command. Therefore, IGP takes precedence over Incomplete in route
selection. In Figure 4-10, Router A and Router B are EBGP peers, and Router B, Router C, and
Router D are IBGP peers.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 56


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Figure 4-10 Networking diagram with Origin configurations

AS 100 AS 65001
Router A Router B Router D
10.1.1.1/30 10.1.1.2/30 10.1.3.1/30
IBGP 10.1.3.2/30
10.1.2.1/30 10.1.4.1/30

IBGP IBGP
Router C
10.1.2.2/30 10.1.4.2/30

The configurations on Router D are as follows:


#
bgp 65001
#
ipv4-family unicast
network 10.1.4.0 255.255.255.252 //Advertise the route
10.1.4.0/30.
#

The configurations on Router C are as follows:


#
bgp 65001
#
ipv4-family unicast
import-route direct //Import direct routes.
#

Run the display bgp routing-table [ ip-address ] command to check the configurations.
# Display the routing table of Router B.
[Router B] display bgp routing-table

BGP Local router ID is 10.1.1.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: 3


Network NextHop MED LocPrf PrefVal Path/Ogn

i 10.1.2.0/30 10.1.2.2 0 100 0 ?


*>i 10.1.4.0/30 10.1.3.2 0 100 0 i
* i 10.1.2.2 0 100 0 ?

The preceding command output shows that two active routes 10.1.4.0/30 are available in the
routing table.
[Router B] display bgp routing-table 10.1.4.0

BGP local router ID : 10.1.1.2


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.1.4.0/30:
From: 10.1.3.2 (10.1.3.2)
Route Duration: 01h14m48s
Relay IP Nexthop: 0.0.0.0
Relay IP Out-Interface: GigabitEthernet0/0/2
Original nexthop: 10.1.3.2

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 57


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Qos information : 0x0


AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best,
select, active, pre 255
Advertised to such 1 peers:
10.1.1.1
BGP routing table entry information of 10.1.4.0/30:
From: 10.1.2.2 (10.1.2.2)
Route Duration: 01h13m20s
Relay IP Nexthop: 0.0.0.0
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, valid, internal,
pre 255, not preferred for Origin
Not advertised to any peer yet

The preceding command output shows that the route learned from Router D is selected because
it is imported using the network command and its Origin priority is higher than that of the route
learned from Router C. Table 4-13 describes the attribute comparison of the routes learned from
Router C and Router D.

Table 4-13 Attribute comparison of the routes learned from Router C and Router D

Route Attribute Route Learned Route Learned Comparison


from Router C from Router D

PrefVal 0 0 The same.

Local_Pref 100 100 The same.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path - - The same length.

Origin Incomplete IGP The route learned


from Router D is
optimal.

The Origin attribute can be modified using a route-policy. In the following example, a route-
policy is configured on Router B to modify the Origin attribute, and the detailed configurations
are as follows:
#
bgp 65001
#
ipv4-family unicast
peer 10.1.3.2 route-policy for_d import //Apply import policy named
for_d to the routes learned from 10.1.3.2 and use for_d to modify the Origin
value.
#
route-policy for_d permit node 10 //Define the route-policy
named for_d.
apply origin incomplete //Set the Origin type to
Incomplete.

Run the display bgp routing-table [ ip-address ] command to check the configurations.
# Display the routing table of Router B.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 58


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

[Router B] display bgp routing-table

BGP Local router ID is 10.1.1.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: 3


Network NextHop MED LocPrf PrefVal Path/Ogn

i 10.1.2.0/30 10.1.2.2 0 100 0 ?


*>i 10.1.4.0/30 10.1.2.2 0 100 0 ?
* i 10.1.3.2 0 100 0 ?

The preceding command output shows that the route learned from Router C becomes the optimal
route.
[Router B] display bgp routing-table 10.1.4.0

BGP local router ID : 10.1.1.2


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.1.4.0/30:
From: 10.1.2.2 (10.1.2.2)
Route Duration: 01h28m19s
Relay IP Nexthop: 0.0.0.0
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, valid, internal,
best, select, active, pre 255
Advertised to such 1 peers:
10.1.1.1
BGP routing table entry information of 10.1.4.0/30:
From: 10.1.3.2 (10.1.3.2)
Route Duration: 00h03m18s
Relay IP Nexthop: 0.0.0.0
Relay IP Out-Interface: GigabitEthernet0/0/2
Original nexthop: 10.1.3.2
Qos information : 0x0
AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, valid, internal,
pre 255, not preferred for router ID
Not advertised to any peer yet

The preceding command output shows that the route learned from Router C becomes the optimal
route because it has a smaller router ID than the route learned from Router D. Table 4-14 shows
the attribute comparison of the routes learned from Router C and Router D.

Table 4-14 Attribute comparison of the routes learned from Router C and Router D

Route Attribute Route Learned Route Learned Comparison


from Router C from Router D

PrefVal 0 0 The same.

Local_Pref 100 100 The same.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path - - The same.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 59


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Route Attribute Route Learned Route Learned Comparison


from Router C from Router D

Origin Incomplete Incomplete The same.

MED 0 0 The same.

Peer type IBGP IBGP The same.

IGP cost - - The same.

Cluster_List - - The same.

Router ID 10.1.2.2 10.1.3.2 The route learned


from Router C is
optimal.

4.8 MED
MED attributes of routes can be configured as required to control traffic forwarding path for the
purpose of load balancing.

The MED attribute is transmitted only within an AS or between two neighboring ASs. The AS
that receives the MED attribute does not advertise it to a third AS.

Similar to the cost used by an IGP, the MED is used to determine the optimal route when traffic
enters an AS. When a BGP peer learns multiple routes that have the same destination address
but different next hop addresses from EBGP peers, the route with the smallest MED value is
selected as the optimal route if all the other attributes are the same.

Table 4-15 lists two methods used to modify the MED value.

Table 4-15 Methods to modify the MED value

Method Usage Scenario

Run the default med command. This method sets a default MED for all the
routes that the local device advertises to its
BGP peers. The default med command takes
effect only with the routes imported locally
using the import-route command and BGP
summarized routes.

Configure an import or export policy and run This method sets different MED values for
the apply cost command to configure an different routes advertised by the local device
apply clause for the policy. to its EBGP peers.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 60


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Method Usage Scenario

Configure an export policy and run the apply This method enables a device to set MED
cost-type internal command to configure an values for the BGP routes that are learned
apply clause for the export policy. from IBGP peers and to be advertised to
EBGP peers and match the export policy to
the costs of the IGP routes to which the BGP
routes are iterated.

The major points about MED attributes that require consideration are as follows:

l If routes are received from different ASs, traffic will be sent to different ASs. In addition,
BGP selects the optimal route only from the routes destined for the same address. Therefore,
BGP only compares the MEDs of routes that are from the same AS (excluding confederation
sub-ASs). MEDs of two routes are compared only if the leftmost AS number in the
AS_Sequence (excluding AS_Confed_Sequence) of one route is the same as its counterpart
in the other route.
l If the compare-different-as-med command is run, BGP compares MEDs of routes even
when the routes are received from peers in different ASs. Do not run this command unless
the ASs use the same IGP and route selection mode. Otherwise, a routing loop may occur.
l If a route does not carry MED, BGP uses the default value (0) as the MED of the route
during route selection. If the bestroute med-none-as-maximum command is run, BGP
considers the largest MED value (4294967295) to be the MED of the route.
l After the bestroute med-confederation command is configured, BGP compares the MEDs
of routes only when the AS_Path attributes of the routes carry no external AS numbers
(ASs that do not belong to the confederation) and the leftmost AS numbers in each
AS_Confed_Sequence are the same.
l After the deterministic-med command is configured, routes will not be selected in the
same sequence they are received.

In Figure 4-11, ISP1 and ISP2 can learn the route 1.1.1.9/32 from Router C or Router D.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 61


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Figure 4-11 Networking diagram for MED applications

Internet

ISP1 ISP2
AS 100 AS 200
10
Router A Router B

0
.1

/3
.3

.1
.1

.4
10.1.1.1/30 /3 10.1.2.1/30

.1
0

10
EBGP EBGP
10
.1
.3
0
/3

.
Client Network 2/30
.2
.4
.1

10.1.1.2/30 AS 65001 10.1.2.2/30


10

10.1.5.1/30
Router C Router D
IBGP 10.1.5.2/30
10.1.6.1/30 10.1.7.1/30

IBGP 1.1.1.9/32 IBGP


10.1.6.2/30 10.1.7.2/30

Router E

Scenario 1: Check the BGP routing tables of Router A and Router B before Router C and Router
D are configured to modify the MED of the route 1.1.1.9/32.
[Router A] display bgp routing-table

BGP Local router ID is 10.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: 2


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 1.1.1.9/32 10.1.1.2 0 65001i


* 10.1.3.2 0 65001i
[Router B] display bgp routing-table

BGP Local router ID is 10.1.2.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: 2


Network NextHop MED LocPrf PrefVal Path/Ogn

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 62


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

*> 1.1.1.9/32 10.1.4.2 0 65001i


* 10.1.2.2 0 65001i

The preceding command output shows that both ISP1 and ISP2 select the route learned from
Router C as the optimal route. As a result, Router C and Router D cannot load-balance the traffic
from ISP1 or ISP2 to 1.1.1.1/32.

Run the display bgp routing-table ip-address command on Router B to check the reason why
Router B chooses the route learned from Router C.
[Router B] display bgp routing-table 1.1.1.9

BGP local router ID : 10.1.2.1


Local AS number : 200
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 1.1.1.9/32:
From: 10.1.4.2 (10.1.1.2)
Route Duration: 00h00m58s
Direct Out-interface: GigabitEthernet0/0/2
Original nexthop: 10.1.4.2
Qos information : 0x0
AS-path 65001, origin igp, pref-val 0, valid, external, best, select, active, pre
255
Advertised to such 2 peers:
10.1.2.2
10.1.4.2
BGP routing table entry information of 1.1.1.9/32:
From: 10.1.2.2 (10.1.2.2)
Route Duration: 00h01m07s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path 65001, origin igp, pref-val 0, valid, external, pre 255, not preferred for
router ID
Not advertised to any peer yet

The preceding command output shows that Router B selects the route learned from Router C
because the router ID (10.1.1.2) of Router C is smaller than that (10.1.2.2) of Router D. Table
4-16 describes the attribute comparison of the routes learned from Router C and Router D.

Table 4-16 Attribute comparison of the routes learned from Router C and Router D

Route Attribute Route Learned Route Learned Comparison


from Router C from Router D

PrefVal 0 0 The same.

Local_Pref - - The same.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path 65001 65001 The same length.

Origin IGP IGP The same.

MED - - The same.

Peer type EBGP EBGP The same.

IGP cost - - The same.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 63


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Route Attribute Route Learned Route Learned Comparison


from Router C from Router D

Cluster_List - - The same length.

Router ID 10.1.1.2 10.1.2.2 The route learned


from Router C is
optimal.

Scenario 2: The requirements of the administrator of AS 65001 are as follows:


l For the traffic from ISP1 to 1.1.1.9/32, the link Router A -> Router C is active and the link
Router A -> Router D is backup.
l For the traffic from ISP2 to 1.1.1.9/32, the link Router B -> Router D is active and the link
Router B -> Router C is backup.

To meet the preceding requirements, ensure that ISP1 selects the route learned from Router C
and that ISP2 selects the route learned from Router D. Figure 4-12 shows the networking in
which MED is used to control route selection.

Figure 4-12 Networking diagram for MED applications

Internet

ISP1 ISP2
AS 100 AS 200
Router A Router B

Set MED: EBGP EBGP Set MED:


100 for 1.1.1.9/32 to ISP2 200 for 1.1.1.9/32 to ISP1

Client Network
AS 65001

Router C Router D
IBGP

To: 1.1.1.9/32 To: 1.1.1.9/32


1.1.1.9/32
IBGP IBGP

Router E

Best route

Configure route-policies to set different MED values for the routes learned from different peers.
Detailed configurations are as follows:
l Configurations on Router C:
#
bgp 65001
#

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 64


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

ipv4-family unicast
undo synchronization
peer 10.1.4.1 route-policy addmed100 export //Apply export policy
named addmed100 to the routes to be advertised to 10.1.4.1 and use addmed100
to modify the MED value.
#
route-policy addmed100 permit node 10 //Define the first node
of addmed100 and set the MED of the route 1.1.1.9/32 to 100.
if-match ip-prefix p1
apply cost 100
#
route-policy addmed100 permit node 20 //Define the second node
of addmed100 to allow addmed100 to permit all other routes.
#
ip ip-prefix p1 index 10 permit 1.1.1.9 32 //Configure an IP prefix
list to match the route 1.1.1.9/32.

l Configurations on Router D:
NOTE

The following configurations are intended to ensure that Router A selects the route learned from
Router C. However, Router A has already selected the route learned from Router C because the router
ID of Router C is smaller than that of Router D. Therefore, the following configurations on Router
D are optional.
#
bgp 65001
#
ipv4-family unicast
undo synchronization
peer 10.1.3.1 route-policy addmed200 export //Apply export policy
named addmed200 to the routes to be advertised to 10.1.3.1 and use addmed200
to modify the MED value.
#
route-policy addmed200 permit node 10 //Define the first node
of addmed200 and set the MED of the route 1.1.1.9/32 to 200.
if-match ip-prefix p1
apply cost 200
#
route-policy addmed200 permit node 20 //Define the second node
of addmed200 to allow addmed200 to permit all other routes.
#
ip ip-prefix p1 index 10 permit 1.1.1.9 32 //Configure an IP prefix
list to match the route 1.1.1.9/32.

Run the display bgp routing-table [ ip-address ] command to check the configurations. Use
Router B as an example.

# Display the routing table of Router B.


[Router B] display bgp routing-table

BGP Local router ID is 10.1.2.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: 2


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 1.1.1.9/32 10.1.2.2 0 65001i


* 10.1.4.2 100 0 65001i

# Display detailed information about the route 1.1.1.9/32 on Router B.


[Router B] display bgp routing-table 1.1.1.9 32

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 65


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

BGP local router ID : 10.1.2.1


Local AS number : 200
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 1.1.1.9/32:
From: 10.1.2.2 (10.1.2.2)
Route Duration: 01h20m38s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path 65001, origin igp, pref-val 0, valid, external, best, select, active, pre
255
Advertised to such 2 peers:
10.1.2.2
10.1.4.2
BGP routing table entry information of 1.1.1.9/32:
From: 10.1.4.2 (10.1.1.2)
Route Duration: 01h16m28s
Direct Out-interface: GigabitEthernet0/0/2
Original nexthop: 10.1.4.2
Qos information : 0x0
AS-path 65001, origin igp, MED 100, pref-val 0, valid, external, pre 255, not
preferred for MED
Not advertised to any peer yet

The preceding command output shows that two routes 1.1.1.9/32 are available in the BGP routing
table of Router B and that only the route with next hop address 10.1.2.2 is selected as the optimal
route.

Table 4-17 describes the attribute comparison of the routes learned from Router C and Router
D.

Table 4-17 Attribute comparison of the routes learned from Router C and Router D

Route Attribute Route Learned Route Learned Comparison


from Router C from Router D

PrefVal 0 0 The same.

Local_Pref - - The same.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path 65001 65001 The same length.

Origin IGP IGP The same.

MED 100 - The route learned


from Router D
carries no MED
value, and therefore,
the default value (0)
is used.
The route learned
from Router D is
optimal.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 66


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Figure 4-12 shows that the route learned from Router D does not carry the MED value. During
route selection, BGP uses the default value (0) as the MED of the route. Therefore, this route is
selected as the optimal route. To change the route selection result on Router B, run the bestroute
med-none-as-maximum command on Router B. Detailed configurations are as follows:
[Router B] display bgp routing-table

BGP Local router ID is 10.1.2.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: 2


Network NextHop MED LocPrf PrefVal Path/Ogn

*> 1.1.1.9/32 10.1.4.2 100 0 65001i


* 10.1.2.2 0 65001i
[Router B] display bgp routing-table 1.1.1.9

BGP local router ID : 10.1.2.1


Local AS number : 200
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 1.1.1.9/32:
From: 10.1.4.2 (10.1.1.2)
Route Duration: 00h08m42s
Direct Out-interface: GigabitEthernet0/0/2
Original nexthop: 10.1.4.2
Qos information : 0x0
AS-path 65001, origin igp, MED 100, pref-val 0, valid, external, best, select,
active, pre 255
Advertised to such 2 peers:
10.1.2.2
10.1.4.2
BGP routing table entry information of 1.1.1.9/32:
From: 10.1.2.2 (10.1.2.2)
Route Duration: 16h33m10s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path 65001, origin igp, pref-val 0, valid, external, pre 255, not preferred for
MED
Not advertised to any peer yet

The preceding command output shows that two routes 1.1.1.9/32 are available in the BGP routing
table of Router B. The MED of the route with the next hop address 10.1.4.2 is 100, and the MED
of the route with the next hop address 10.1.2.2 is considered as 4294967295 because it carries
no MED. Therefore, the route with the next hop address 10.1.4.2 is selected as the optimal route.

In addition, BGP selects routes in the same sequence they are received. Therefore, the route
selection result is relevant to the sequence in which the routes are received. For example, the
following three BGP routes are available on a device:

l Route A1: AS_Path { 65001 200 }, med 100, igp cost 13, internal, Router id 4.4.4.4
l Route A2: AS_Path { 65001 100 }, med 150, igp cost 11, internal, Router id 5.5.5.5
l Route B: AS_Path { 65002 300 }, med 0, igp cost 12, internal, Router id 6.6.6.6

If the compare-different-as-med (BGP) command is run, route B is the optimal route,


regardless of the sequence in which the routes are received. If the compare-different-as-med
(BGP) command is not configured, BGP does not compare the MED values of routes learned
from different ASs. The route selection is described in the following cases:

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 67


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

l Case 1: Route A1 is received first, followed by route B, and then route A2.
– BGP first compares route A1 and route B. The leftmost AS number in the AS_Path of
route A1 is 65001, which is different from its counterpart in route B (65002). Therefore,
BGP does not compare the MED values, and prefers route B to route A1 because the
IGP cost (12) of route B is smaller than that of route A1 (13).
– BGP then compares route A2 and route B. The leftmost AS number in the AS_Path of
route A2 is 65001, which is different from its counterpart in route B (65002). Therefore,
BGP does not compare the MED values, and selects route A2 as the optimal route
because its IGP cost (11) is smaller than that of route B (12).
l Case 2: Route A2 is received first, followed by route B, and then route A1.
– BGP then compares route A2 and route B. The leftmost AS number in the AS_Path of
route A2 is 65001, which is different from its counterpart in route B (65002). Therefore,
BGP does not compare the MED values and prefers route A2 to route B because the
IGP cost (11) of route A2 is smaller than that of route B (12).
– BGP then compares route A1 and route A2. The leftmost AS number in the AS_Path
of route A1 is the same as its counterpart in route A2 (65001). In this situation, BGP
selects route A1 as the optimal route because its MED value (100) is smaller than that
of route A2 (150).
l Case 3: If the deterministic-med command is run, BGP groups the routes that are learned
from different ASs but are destined for the same network segment based on the leftmost
AS number in the AS_Path, selects one optimal route from each group, and then compares
the optimal routes of all the groups. Detailed steps are as follows:
– BGP first compares route A1 and route A2. The leftmost AS number in the AS_Path of
route A1 is the same as its counterpart in route A2 (65001). In this situation, BGP selects
route A1 as the optimal route because its MED value (100) is smaller than that of route
A2 (150).
– BGP then compares route A1 and route B. The leftmost AS number in the AS_Path of
route A1 is 65001, which is different from its counterpart in route B (65002). Therefore,
BGP does not compare the MED values and selects route B as the optimal route because
the IGP cost (12) of route B is smaller than that of route A1 (13).

Case 1 and case 2 show that the route selection result is relevant to the sequence in which routes
are received if the deterministic-med is not configured. Case 3 shows that the route selection
result is irrelevant to the sequence in which routes are received if the deterministic-med is
configured.

4.9 Peer Type


When IBGP routes (routes learned from IBGP peers) and EBGP routes (routes learned from
EBGP peers) are available, BGP preferentially selects EBGP routes.

When one EBGP route and multiple IBGP routes are available, BGP selects the optimal route
based on the peer type. If no EBGP route is available or multiple EBGP routes are available,
BGP is unable to select the optimal route based on the peer type.

When multiple egress devices reside on a carrier network and receive routes from the Internet,
the egress devices select the optimal route based on the peer type in most cases. In Figure
4-13, all devices reside in the same AS, Router A and Router B function as egress devices and
are IBGP peers of all devices in the AS. In addition, Router A and Router B receive routes from

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 68


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

the Internet and advertise EBGP routes to all their IBGP peers. Therefore, Router A and Router
B have an IBGP route and an EBGP route, and the two routes have the same AS_Path. In this
situation, Router A and Router B select the EBGP route as the optimal route.

Figure 4-13 Peer type application networking

Internet

EBGP EBGP

Router A Router B

IBGP

The EBGP route is selected as the optimal route, which prevents the traffic that leaves Router
A or Router B for the Internet from being forwarded to the other egress device.

For more peer type-based route selection examples, see 4.3 Local_Pref.

4.10 IGP Cost


BGP prefers the route with the smallest IGP cost during BGP route selection.

This rule helps BGP to choose the route with the smallest cost to its iterated next hop address
quickly. In V600R008C00 and the later versions, if the bestroute igp-metric-ignore command
is configured, BGP does not compare the IGP cost.

In Figure 4-14, OSPF runs in AS 65001, an EBGP peer relationship is established between
Router E and Router A and between Router E and Router B, and an IBGP peer relationship is
established between Router A and Router C, between Router A and Router D, between Router
B and Router C, and between Router B and Router D; Router E is configured to import routes
(1.1.1.9/32 for example) from AS 100 to BGP.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 69


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Figure 4-14 Networking diagram with IGP cost configurations

ISP
AS 100

1.1.1.9/32

10.1.5.2/30 10.1.6.2/30

EBGP RouterE EBGP


10.1.5.1/30 10.1.6.1/30

10.1.4.1/30
RouterA 10.1.4.2/30 RouterB
10.1.3.2/30 10.1.3.2/30
AS 65001

10.1.3.1/30 10.1.3.1/30
10.1.2.1/30
RouterC 10.1.2.2/30 RouterD

Run the display bgp routing-table [ ip-address ] command on Router C and Router D to check
the configurations. Router C is used as an example.
# Display the routing table of Router C.
[Router C] display bgp routing-table

BGP Local router ID is 10.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: 4


Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 1.1.1.9/32 10.1.5.2 0 100 0 100i


* i 10.1.6.2 0 100 0 100i
*>i 10.1.5.0/30 10.1.3.2 0 100 0 i
*>i 10.1.6.0/30 10.1.2.2 0 100 0 i

The preceding command output shows that two routes 1.1.1.9/32 are available in the routing
table of Router C and that Router C selects the route learned from Router A.
[Router C] display bgp routing-table 1.1.1.9

BGP local router ID : 10.1.1.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 1.1.1.9/32:
From: 10.1.3.2 (2.2.2.9)
Route Duration: 00h00m44s
Relay IP Nexthop: 10.1.3.2
Relay IP Out-Interface: GigabitEthernet0/0/0

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 70


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Original nexthop: 10.1.5.2


Qos information : 0x0
AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best,
select, active, pre 255
Not advertised to any peer yet

BGP routing table entry information of 1.1.1.9/32:


From: 10.1.2.2 (10.1.2.2)
Route Duration: 00h00m39s
Relay IP Nexthop: 10.1.1.2
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 10.1.6.2
Qos information : 0x0
AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre
255, IGP cost 2, not preferred for IGP cost
Not advertised to any peer yet

The preceding command output shows that the route with next hop address 10.1.6.2 is ignored
because its IGP cost is larger than that of the other route. Table 4-18 describes the attribute
comparison of the routes learned from Router A and Router B.

Table 4-18 Attribute comparison of the routes learned from Router A and Router B.

Route Attribute Route Learned Route Learned Comparison


from Router A from Router B

PrefVal 0 0 The same.

Local_Pref 100 100 The same.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path 100 100 The same length.

Origin IGP IGP The same.

MED 0 0 The same.

Peer type IBGP IBGP The same.

IGP cost - 2 The route learned


from Router A is
optimal.
NOTE
If a BGP route carries
no IGP cost value,
BGP considers its IGP
cost to be 0. If no IGP
routes are used during
BGP peer relationship
establishment or the
costs of used IGP
routes are 0, the IGP
cost is not displayed in
the display bgp
routing-table ip-
address command
output.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 71


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

4.11 Cluster_List
BGP prefers the route with the shortest Cluster_List length during BGP route selection.

An RR and its clients form a cluster. In an AS, each RR is uniquely identified by a Cluster_ID.

Similar to an AS_Path, a Cluster_List is composed of a series of Cluster_IDs and is generated


by an RR. The Cluster_List records all the RRs through which a route passes.

l Before an RR reflects a route between its clients or between its clients and non-clients, the
RR adds the local Cluster_ID to the leftmost position of the Cluster_List. If a route does
not carry any Cluster_List, the RR creates one for the route.
l After the RR receives an updated route, it checks the Cluster_List of the route. If the RR
finds that its cluster ID is included in the Cluster_List, the RR discards the route. If its
cluster ID is not included in the Cluster_List, the RR adds its cluster ID to the Cluster_List
and then reflects the route.

The following example shows how Cluster_List is used in BGP route selection. In Figure
4-15, an IBGP peer relationship is established between each two neighboring devices in AS
65001. Router B functions as a level-1 RR, and Router D is its client. Router D functions as a
level-2 RR, and Router E is its client. Router C functions as an RR, and Router E is its client.
Router E is configured to import the route 1.1.1.9/32 to BGP.

Figure 4-15 Networking diagram with Cluster_List configurations

Cluster 2 Cluster 1
RR2 RR1

10.1.2.1/30 10.1.2.2/30
10.1.1.2/30 10.1.4.1/30
Router B Router D

10.1.1.1/30
10.1.4.2/30
1.1.1.9/32

AS 65001
Router A Router E

10.1.5.2/30
10.1.3.1/30
Router C

10.1.3.2/30 10.1.5.1/30
RR3 BGP Update
Cluster3

Run the display bgp routing-table [ ip-address ] command on Router A to check the
configurations.

# Display the routing table of Router A.


[Router A] display bgp routing-table

BGP Local router ID is 10.1.3.1


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

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 72


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Total Number of Routes: 2


Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 1.1.1.9/32 10.1.5.2 0 100 0 i


* i 10.1.4.2 0 100 0 i

The preceding command output shows that two routes 1.1.1.9/32 are available in the routing
table of Router C and that Router A selects the route learned from Router C.
[Router A] display bgp routing-table 1.1.1.9

BGP local router ID : 10.1.3.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 1.1.1.9/32:
From: 10.1.3.2 (2.2.2.9)
Route Duration: 00h53m08s
Relay IP Nexthop: 10.1.3.2
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 10.1.5.2
Qos information : 0x0
AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best,
select, active, pre 255, IGP cost 3
Originator: 1.1.1.9
Cluster list: 0.0.0.3
Not advertised to any peer yet

BGP routing table entry information of 1.1.1.9/32:


From: 10.1.1.2 (10.1.2.1)
Route Duration: 00h28m05s
Relay IP Nexthop: 10.1.1.2
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 10.1.4.2
Qos information : 0x0
AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre
255, IGP cost 3, not preferred for Cluster List
Originator: 1.1.1.9
Cluster list: 0.0.0.2, 0.0.0.1
Not advertised to any peer yet

The preceding command output shows that the route learned from Router B is ignored because
its Cluster_List is longer than that of the route learned from Router C. Table 4-19 describes
attribute comparison of the routes learned from Router B and Router C.

Table 4-19 Attribute comparison of the routes learned from Router B and Router C

Route Attribute Route Learned Route Learned Comparison


from Router B from Router C

PrefVal 0 0 The same.

Local_Pref 100 100 The same.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path - - The same length.

Origin IGP IGP The same.

MED 0 0 The same.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 73


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Route Attribute Route Learned Route Learned Comparison


from Router B from Router C

Peer type IBGP IBGP The same.

IGP cost 3 3 The same.

Cluster_List 0.0.0.2, 0.0.0.1 0.0.0.3 The route learned


from Router C is
optimal.

In most cases, BGP does not advertise the routes learned from an AS to the AS again. When
RRs are deployed, such routes may be advertised to the AS again although routing loops may
occur. Using the Cluster_List attribute can prevent such routing loops.

4.12 Originator_ID
If routes carry the Originator_ID, the originator ID is substituted for the router ID during route
selection. The route with the smallest Originator_ID is preferred.
The Originator_ID attribute is four bytes long and is generated by an RR. It carries the router
ID of the route originator in the local AS.
l When a route is reflected by an RR for the first time, the RR adds the Originator_ID to this
route. If a route already carries the Originator_ID attribute, the RR does not create a new
one.
l After receiving the route, a BGP speaker checks whether the Originator_ID is the same as
its router ID. If Originator_ID is the same as its router ID, the BGP speaker discards this
route.
The following example shows how Originator_ID is used during BGP route selection. In Figure
4-16, an IBGP peer relationship is established between each two neighboring devices in AS
65001. The router IDs of Router B and Router C are 2.2.2.9 and 3.3.3.9, respectively, and they
function as RRs. Router D is a client of Router B, and Router E is a client of Router C. Router
D and Router E are configured to import the route 10.1.4.0/30 to BGP.

Figure 4-16 Networking diagram with Originator_ID configurations

Cluster 2
RR2

10.1.2.1/30 10.1.2.2/30
10.1.1.2/30 10.1.4.2/30
Router B Router D

10.1.1.1/30
10.1.4.1/30
AS 65001
Router A Router E

10.1.5.2/30
10.1.3.1/30
RouterC

10.1.3.2/30 10.1.5.1/30
RR3 BGP Update
Cluster 3

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 74


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Run the display bgp routing-table [ ip-address ] command on Router A to check the
configurations.

# Display the routing table of Router A.


[Router A] display bgp routing-table

BGP Local router ID is 10.1.3.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: 2


Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 10.1.4.0/30 10.1.5.2 0 100 0 i


* i 10.1.2.2 0 100 0 i

The preceding command output shows that two routes 10.1.4.0/30 are available in the routing
table of Router A and that Router A selects the route learned from Router C.
[Router A] display bgp routing-table 1.1.1.9

BGP local router ID : 10.1.3.1


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 10.1.4.0/30:
From: 10.1.3.2 (3.3.3.9)
Route Duration: 00h00m01s
Relay IP Nexthop: 10.1.3.2
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 10.1.5.2
Qos information : 0x0
AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best,
select, pre 255, IGP cost 2
Originator: 10.1.4.1
Cluster list: 0.0.0.3
Not advertised to any peer yet

BGP routing table entry information of 10.1.4.0/30:


From: 10.1.1.2 (2.2.2.9)
Route Duration: 00h00m17s
Relay IP Nexthop: 10.1.1.2
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre
255, IGP cost 2, not preferred for router ID
Originator: 10.1.4.2
Cluster list: 0.0.0.2
Not advertised to any peer yet

The preceding command output shows that the route learned from Router B is not selected due
to a router ID issue. In fact, the router ID of Router B is 2.2.2.9, smaller than that (3.3.3.9) of
Router C. The route learned from Router B should be selected if the router IDs are used to
determine the optimal route. However, the routes carry Originator_ID attributes. In this situation,
the Originator_ID attributes (rather than router IDs) are compared. Router A selects the route
learned from Router C because its Originator_ID (10.1.4.1) is smaller than that (10.1.4.2) of the
route learned from Router B.

Table 4-20 describes the attribute comparison of the routes learned from Router B and Router
C.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 75


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Table 4-20 Attribute comparison of the routes learned from Router B and Router C

Route Attribute Route Learned Route Learned Comparison


from Router B from Router C

PrefVal 0 0 The same.

Local_Pref 100 100 The same.

Route type Learned from a peer Learned from a peer The same.

AIGP - - The same.

AS_Path - - The same length.

Origin IGP IGP The same.

MED 0 0 The same.

Peer type IBGP IBGP The same.

IGP cost 2 2 The same.

Cluster_List 0.0.0.2 0.0.0.3 The same length.

Originator_ID 10.1.4.2 10.1.4.1 The route learned


from Router C is
optimal.

If routes carry Originator_ID attributes, the Originator_ID attributes (rather than router IDs) are
compared.

4.13 Router ID
If multiple routes to the same destination are available, BGP preferentially selects the route
advertised by the device with the smallest router ID.

A router ID uniquely identifies a router in an AS, and the router ID can be configured as follows:
l Run the router-id { ipv4-address | vpn-instance auto-select } command. If no router ID
is configured in the BGP view, BGP selects a router ID configured in the system view. For
details on how a router ID configured in the system view is selected, see router-id.
l Run the router-id (BGP) { ipv4-address | auto-select } command in the BGP VPN instance
IPv4/IPv6 address family view. The router-id (BGP VPN instance IPv4/IPv6 address
family view) command takes precedence over the router-id (BGP) command.

If each route carries an Originator_ID, the Originator_IDs rather than router IDs are compared
during route selection. The route with the smallest Originator_ID is preferred.

In V600R008 and the later versions, by default, Cluster_List takes precedence over
Originator_ID during BGP route selection. To enable Originator_ID to take precedence over
Cluster_List during BGP route selection, run the bestroute router id-prior-clusterlist
command.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 76


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

For more router ID-based route selection examples, see 4.3 Local_Pref, 4.7 Origin, and
MED.

4.14 Peer IP Address


BGP prefers the route learned from the peer with the smallest IP address during BGP route
selection.
The peer IP address is the IP address specified in ipv4-address or ipv6-address in the peer
{ group-name | ipv4-address | ipv6-address } as-number { as-number-plain | as-number-dot }
command. The group-name parameter specified in the command is the one specified in the
peer { ipv4-address | ipv6-address } group group-name command.
If the optimal route has not been selected yet before BGP begins to compare peer IP addresses,
the local device may have established multiple BGP peer relationships with another device
through equal-cost links. In most cases, if a backup physical link is available between two
devices, using loopback interfaces to establish a BGP peer relationship is recommended although
multiple BGP peer relationships may be established between the two devices through the
physical links.
In Figure 4-17, two physical links are available between Router A and Router B. Router A and
Router B can use loopback interfaces to establish a BGP peer relationship or use the two links
to establish two BGP peer relationships. In the following example, the two links are used to
establish two BGP peer relationships to show how peer addresses are used in route selection.

Figure 4-17 Networking in which two links are used to establish two BGP peer relationships

AS 65001 AS 65002
10.1.1.1/30 10.1.1.2/30
1.1.1.9/32 2.2.2.9/32
10.1.2.1/30 10.1.2.2/30
Router A Router B

The configurations on Router A are as follows:


#
bgp 65001
peer 10.1.1.2 as-number 65002
peer 10.1.2.2 as-number 65002
#
ipv4-family unicast
peer 10.1.1.2 enable
peer 10.1.2.2 enable
#

The configurations on Router B are as follows:


#
bgp 65002
peer 10.1.1.1 as-number 65001
peer 10.1.2.1 as-number 65001
#
ipv4-family unicast
network 2.2.2.9 255.255.255.255
peer 10.1.1.1 enable
peer 10.1.2.1 enable
#

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 77


Copyright © Huawei Technologies Co., Ltd.
Special Topic - BGP Route Selection 4 Route Attributes

Run the display bgp routing-table [ ip-address ] command to check the configurations.

# Display the routing table of Router A.


[Router A] display bgp routing-table

BGP Local router ID is 192.168.2.3


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

*> 2.2.2.9/32 10.1.1.2 0 0 65002i


* 10.1.2.2 0 0 65002i

The preceding command output shows that two routes 2.2.2.9/32 are available in the routing
table and that the route with the next hop address 10.1.1.2 is selected as the optimal route.
[Router A] display bgp routing-table 2.2.2.9

BGP local router ID : 192.168.2.3


Local AS number : 65001
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 2.2.2.9/32:
From: 10.1.1.2 (192.168.2.4)
Route Duration: 00h19m10s
Direct Out-interface: GigabitEthernet1/0/5
Original nexthop: 10.1.1.2
Qos information : 0x0
AS-path 65002, origin igp, MED 0, pref-val 0, valid, external, best, select,
active, pre 255
Advertised to such 2 peers:
10.1.1.2
10.1.2.2
BGP routing table entry information of 2.2.2.9/32:
From: 10.1.2.2 (192.168.2.4)
Route Duration: 00h19m05s
Direct Out-interface: GigabitEthernet1/0/10
Original nexthop: 10.1.2.2
Qos information : 0x0
AS-path 65002, origin igp, MED 0, pref-val 0, valid, external, pre 255, not
preferred for peer address
Not advertised to any peer yet

The preceding command output shows that the route with the next hop address 10.1.1.2 is
selected as the optimal route because its peer IP address is smaller than that of the other route.

Issue 1.0 (2014-6-12) Huawei Proprietary and Confidential 78


Copyright © Huawei Technologies Co., Ltd.

Das könnte Ihnen auch gefallen