preference

Use preference to configure preferences for BGP routes.

Use undo preference to restore the default.

Syntax

preference { external-preference internal-preference local-preference | route-policy route-policy-name }

undo preference

Default

The preferences of external, internal, and local BGP routes are 255, 255, and 130.

Views

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

Predefined user roles

network-admin

mdc-admin

Parameters

external-preference: Specifies a preference for EBGP routes, in the range of 1 to 255.

internal-preference: Specifies a preference for IBGP routes, in the range of 1 to 255.

local-preference: Specifies a preference for local routes, in the range of 1 to 255.

route-policy route-policy-name: Specifies a routing policy by its name, a case-sensitive string of 1 to 63 characters, to set the route preference for matching routes. Routes not matching the routing policy use the default preference.

Usage guidelines

Different routing protocols might find different routes to the same destination. However, not all of those routes are optimal. For route selection, routing protocols, direct routes, and static routes are assigned different preferences. The route with the highest preference is preferred.

Configuring the preferences for BGP routes changes the possibility for the routes to become the optimal route.

To reference a routing policy to set the preference, you must configure the preference with the apply preference command in the routing policy in advance. Otherwise, all matching routes use the default preference.

Examples

# In BGP IPv4 unicast address family view, configure preferences for EBGP, IBGP, and local routes as 20, 20, and 200.

<Sysname> system-view
[Sysname] bgp 100
[Sysname-bgp] address-family ipv4 unicast
[Sysname-bgp-ipv4] preference 20 20 200

# In BGP IPv4 unicast address family view, configure the preference for BGP route 1.1.1.0/24 as 200.

<Sysname> system-view
[Sysname] ip prefix-list route permit 1.1.1.0 24
[Sysname] route-policy prefer permit node 0
[Sysname-route-policy-prefer-0] if-match ip address prefix-list route
[Sysname-route-policy-prefer-0] apply preference 200
[Sysname-route-policy-prefer-0] quit
[Sysname] bgp 100
[Sysname-bgp] address-family ipv4 unicast
[Sysname-bgp-ipv4] preference route-policy prefer

# In BGP-VPN IPv6 unicast address family view, configure preferences for EBGP, IBGP, and local routes as 20, 20, and 200.

<Sysname> system-view
[Sysname] bgp 100
[Sysname-bgp] ip vpn-instance vpn1
[Sysname-bgp-vpn1] address-family ipv6 unicast
[Sysname-bgp-ipv6-vpn1] preference 20 20 200