preference (BGP)
Function
The preference command sets protocol preferences for EBGP routes, IBGP routes, and local BGP routes.
The undo preference command restores the default setting.
By default, the protocol preferences of EBGP routes, IBGP routes, and local BGP routes are all 255.
Format
preference external internal local [ route-policy route-policy-name ]
preference route-policy route-policy-name
undo preference
Parameters
Parameter | Description | Value |
---|---|---|
external | Specifies the protocol preference of an EBGP route. An EBGP route is the optimal route learned from a peer outside the local AS. | The value is an integer ranging from 1 to 255. The smaller the value is, the higher the preference is. |
internal | Specifies the protocol preference of an IBGP route. An IBGP route is a route learned from a peer inside the AS. | The value is an integer ranging from 1 to 255. The smaller the value is, the higher the preference is. |
local | Specifies the protocol preference of a local BGP route. A local BGP route is a route obtained by using the summary automatic command (automatic summarization) or the aggregate (BGP) command (manual aggregation). | The value is an integer ranging from 1 to 255. The smaller the value is, the higher the preference is. |
route-policy route-policy-name | Specifies the name of a route-policy. | It is a string of 1 to 40 case-sensitive characters without any spaces. |
Usage Guidelines
Usage Scenario
Running the preference command to set protocol preferences for BGP routes affects route selection among BGP routes and routes of other routing protocols.
After a route-policy is configured on a device, the device sets preferences only for the routes received from peers, which meet the matching rules. The routes that do not meet the rules use the default preference.
The smaller the preference value, the higher the preference.
Different protocol preferences can be configured for BGP routes in different address family views.
Prerequisites
Create the route-policy first if the preference command uses the route-policy to set preferences.
Perform the following steps when the route-policy is used to set preferences:
Use the route-policy command to create the route-policy, and enter the route-policy view.
Configure the if-match clause to set the matching rules for routes. The relationship between the if-match clauses in a node of a route-policy is "AND". A route must match all the rules before the action defined by the apply clause is taken. If no if-match clause is specified, all routes will match the node in the route-policy.
Use the apply preference command to set preferences for routes that pass the filtering.
Precautions
Currently, the peer route-policy command cannot be used to apply a route-policy to setting preferences for BGP routes.
The preference command cannot configure a priority for routes imported using the network command or the import-route command. The priority for these routes is 0.
Creating a route-policy before it is referenced is recommended. By default, nonexistent route-policies cannot be referenced using the command.
- Manually aggregated routes generated using the aggregate (BGP) command. The Route type field for this type of route displays Aggregated route. For example:
<AC6605> 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 ...
- Automatically aggregated routes generated using the summary automatic command. The route type for these routes displays Summary
automatic route. For example:
<AC6605> 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: Summary automatic 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 ...
- Routes generated through remote route cross. The route type for
these routes displays Remote-Cross route. For example:
[AC6605-diagnose] display bgp vpnv4 vpn-instance vrf routing-table 172.16.17.161 BGP local router ID : 10.17.0.17 Local AS number : 100 VPN-Instance vrf, Router ID 10.17.0.17: Paths: 1 available, 1 best, 1 select BGP routing table entry information of 172.16.17.161/32: Remote-Cross route Label information (Received/Applied): 155665/NULL From: 10.216.0.1 (10.17.0.9) Route Duration: 3d04h26m28s Relay Tunnel Out-Interface: Vlanif100 Relay token: 0x24e7 Relay Tunnel Key: 7 Original nexthop: 10.216.0.1 Qos information : 0x0 Ext-Community:RT <10 : 10> AS-path 100, origin incomplete, localpref 150, pref-val 1, valid, internal, best, select, active, pre 255, IGP cost 1 ...
- Routes generated through local route cross. The route type for
these routes displays Local-Cross route. For example:
[AC6605-diagnose] display bgp vpnv4 vpn-instance vrf1 routing-table 10.2.2.0 BGP local router ID : 10.1.1.1 Local AS number : 100 VPN-Instance vrf1, Router ID 10.1.1.1: Paths: 1 available, 1 best, 1 select BGP routing table entry information of 10.2.2.0/24: Local-Cross route(via VPN-Instance vrf2) Route Duration: 00h26m00s Direct Out-interface: Vlanif40 Original nexthop: 10.2.2.2 Qos information : 0x0 Ext-Community:RT <100 : 1> AS-path Nil, origin incomplete, MED 0, pref-val 0, valid, local, best, select, active, pre 255 ...