Beruflich Dokumente
Kultur Dokumente
Issue 1.0
Date 2014-6-12
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.
Website: http://www.huawei.com
Email: support@huawei.com
Overview
This document describes detailed BGP route selection rules on Huawei devices using VRP
software platform.
Intended Audience
This document is intended for:
Command Conventions
Convention Description
Convention Description
&<1-n> The parameter before the & sign can be repeated 1 to n times.
Change History
Version Release Date Change History
Contents
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.
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
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.
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.
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.
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
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.
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
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.
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.
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.
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.
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.
Table 3-1 lists all the common route attributes that affect route selection and the commands that
are used to check them.
The following example describes how to check BGP route attributes in the display bgp routing-
table command output.
<HUAWEI> display bgp routing-table
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
Item Description
MED MED value of a BGP route, similar to the cost of IGP routes
LocPrf Local_Pref
Item Description
PrefVal PrefVal
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
Item Description
BGP local router Router ID of the local device, in the same format as an IPv4 address.
ID
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.
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
Item Description
MED MED value of a BGP route, similar to the cost of IGP routes.
localpref Local_Pref
pref-val PrefVal
AIGP AIGP
Not advertised to The route has not advertised to any peer yet.
any peer yet
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
4 Route Attributes
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.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.11 Cluster_List
BGP prefers the route with the shortest Cluster_List length during BGP route selection.
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.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.
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.
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.
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
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.
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
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.
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.
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.
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
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
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 type Learned from a peer Learned from a peer The same.
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
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
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.
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.
* 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.
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.
Run the default local-preference command. This method sets a default Local_Pref for the
routes that the local device advertises to IBGP
peers.
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.
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
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
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 type Learned from a peer Learned from a peer The same.
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
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
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 type Learned from a peer Learned from a peer The same.
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
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.
The preceding command output shows that Router A selects the routes learned from ISP1.
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
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
Router C selects the routes advertised by ISP1 because Router B did not advertise the routes
learned from ISP2 to Router C.
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:
Internet
10.11.0.0/16
10.22.0.0/16
ISP1 ISP2
AS 100 AS 200
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
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
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.
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
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.
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.
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:
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
Run the display bgp routing-table [ ip-address ] command to check the configurations.
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
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
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.
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.
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:
In Figure 4-6, Router A and Router B are EBGP peers, and Router B, Router C, and Router D
are IBGP peers.
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
Run the display bgp routing-table [ ip-address ] command to check the configurations.
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
The preceding command output shows that the route imported using the network command is
selected as the optimal route.
Run the display bgp routing-table [ ip-address ] command to check the configurations.
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
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:
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.
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
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
#
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.
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 type Learned from a peer Learned from a peer 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.
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.
Item Description
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 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.
Item Description
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.
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.
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.
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.
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 type Learned from a peer Learned from a peer The same.
AS_Path 65002 65004 65005 65003 65003 65003 The route learned
65003 65005 from Router B is
optimal.
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
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
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
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.
4.7 Origin
The Origin attribute indicates how routes become BGP routes.
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.
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
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
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
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 type Learned from a peer Learned from a peer The same.
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.
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
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 type Learned from a peer Learned from a peer The same.
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.
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.
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.
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.5.1/30
Router C Router D
IBGP 10.1.5.2/30
10.1.6.1/30 10.1.7.1/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
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
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 type Learned from a peer Learned from a peer The same.
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.
Internet
ISP1 ISP2
AS 100 AS 200
Router A Router B
Client Network
AS 65001
Router C Router D
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
#
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.
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 type Learned from a peer Learned from a peer The same.
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
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
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.
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
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.
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.
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.
ISP
AS 100
1.1.1.9/32
10.1.5.2/30 10.1.6.2/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
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
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 type Learned from a peer Learned from a peer The same.
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.
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.
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.
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
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 type Learned from a peer Learned from a peer The same.
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.
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
Run the display bgp routing-table [ ip-address ] command on Router A to check the
configurations.
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
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.
Table 4-20 Attribute comparison of the routes learned from Router B and Router C
Route type Learned from a peer Learned from a peer The same.
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.
For more router ID-based route selection examples, see 4.3 Local_Pref, 4.7 Origin, and
MED.
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
Run the display bgp routing-table [ ip-address ] command to check the configurations.
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
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.