< Home

preference (BGP)

Function

The preference command configures the preferences for external, internal, and local routes. You can configure different preferences for BGP routes in the different address family views.

The undo preference command restores the default value.

By default, the preference values of EBGP external routes, IBGP internal routes, and BGP local 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 the EBGP external routes. External routes are the optimal routes learned from a peer outside the AS. It is an integer that ranges from 1 to 255. The smaller the value is, the higher the preference is.
internal Specifies the preference for IBGP internal routes. Internal routes are the optimal routes learned from other peers within the same AS. It is an integer that ranges from 1 to 255. The smaller the value is, the higher the preference is.
local Specifies the protocol preference for aggregated and crossed routes. This parameter takes effect for the following routes:
  • Manually summarized routes generated using the aggregate (BGP) command
  • Automatically summarized routes generated using the summary automatic command
  • Routes generated through remote route cross
  • Routes generated through local route cross
For details about these routes, see Precautions.
It is an integer that ranges from 1 to 255. The smaller the value is, the higher the preference is.
route-policy route-policy-name Specifies the name of the Route-Policy. The name is a string of 1 to 40 case-sensitive characters, with spaces not supported. When double quotation marks are used around the string, spaces are allowed in the string.

Views

BGP view, BGP-VPN instance IPv4 address family view, BGP-VPN instance IPv6 address family view, BGP-IPv6 unicast address family view, BGP-IPv4 unicast address family view, BGP-IPv4 multicast address family view

Default Level

2: Configuration level

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 that 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.

If both external internal local and route-policy route-policy-name are specified in the command, the priority of the routes that match the route-policy is set based on the route-policy, and the priorities of other routes are set based on the external internal local configuration.

Prerequisites

If the preference command is used to set route preference, a Route-Policy needs to be created in advance.

The procedure of using a Route-Policy to set route preference is as follows:
  • Use the route-policy command to create a Route-Policy and enter the Route-Policy view.
  • Configure if-match clauses to set the route matching rules. For a node of a route-policy, the relationship between the if-match clauses is "AND". A route must meet all the matching rules before the action defined by the apply clause is performed. If no if-match clause is specified, all the routes are matched.
  • Run the apply preference command to set preference for the filtered routes.

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 the preference for routes imported using the network command or the import-route command. The preference 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. If the route-policy nonexistent-config-check disable command is run in the system view and a nonexistent route-policy is referenced using the current command, the configured priority is set for all routes; if no priority is configured, the default priority is set for the routes.

In this command, the local parameter specifies the protocol preference for aggregated routes and crossed routes. This parameter takes effect for the following routes:
  • Manually aggregated routes generated using the aggregate (BGP) command. The Route type field for this type of route displays Aggregated route. For example:
    <sysname> 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:
    <sysname> 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:
    [sysname-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:
    [sysname-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
    ...

Example

# Consider the BGP view as an example. The preference of IBGP routes is higher than the routes learned from IGP. So, you need to configure a lower preference administrative value.

<sysname> system-view
[sysname] bgp 100
[sysname-bgp] ipv4-family unicast
[sysname-bgp-af-ipv4] preference 2 2 20

# Set the preference of a route with the prefix of 10.1.0.0/16 to 100.

<sysname> system-view
[sysname] ip ip-prefix aa permit 10.1.0.0 16
[sysname] route-policy bb permit node 10
[sysname-route-policy] if-match ip-prefix aa
[sysname-route-policy] apply preference 100
[sysname-route-policy] quit
[sysname] bgp 100
[sysname-bgp] ipv4-family unicast
[sysname-bgp-af-ipv4] preference route-policy bb
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >