Resumen de Preferencia Local BGP

Preferencia Local BGP: Guía Completa para Estudiantes

Introduction

BGP Local Preference (LocalPref) is a key BGP attribute used to control the outbound exit path selection inside a single Autonomous System (AS). It is an attribute exchanged among iBGP peers and allows network operators to express preference for which egress router traffic should use when leaving the AS.

Definition: Local Preference is a well-known discretionary BGP attribute that indicates the preferred exit path for routes inside an Autonomous System; higher values are more preferred.

What Local Preference Controls

  • Local Preference affects outbound (egress) path selection within your AS. It does not influence inbound traffic coming from other ASes.
  • It is advertised to all iBGP peers (internal BGP), so a LocalPref set on one iBGP speaker can propagate to others.
  • LocalPref is not sent to eBGP peers (external BGP).

Attribute Properties and Defaults

  • Type: Well-known discretionary (must be recognized by all BGP implementations but may be omitted in updates).
  • Default value: 100 unless configured otherwise.

Definition: A well-known discretionary attribute is one that every BGP implementation must recognize, but including it in an update message is optional.

How Local Preference Is Configured

There are two common configuration approaches:

  1. Global default: configure a default LocalPref value for the router. Example command on many vendors: bgp default local-preference <value> (vendor-specific syntax).
  2. Per-neighbor or per-route using route-maps: apply route-maps on BGP neighbors to set LocalPref selectively based on match conditions (prefix, community, AS path, etc.).

Tip: Route-maps provide much finer control than changing a global default since you can match specific prefixes or attributes.

Important operational notes

  • Because LocalPref is propagated via iBGP, it is a convenient alternative to configuring the proprietary weight attribute on every router when you want consistent egress preference across the AS.
  • Remember to actually apply (bind) the route-map to the neighbor session; creating a route-map alone has no effect until attached to a neighbor or process.

Practical Examples

  1. Simple scenario: Two edge routers R1 and R2 connect to different ISPs. If you want all internal routers to prefer egress via R1, set a higher LocalPref on routes learned from R1. All iBGP peers will then prefer the R1-learned paths.

  2. Selective preference using route-map: Match prefixes from a partner or community and set LocalPref to a higher value for those prefixes only. This lets you prefer one ISP for specific destinations while keeping defaults for others.

Example configuration (conceptual)

  • Global default approach: set LocalPref to 200 to prefer this router as exit for all received routes.
  • Route-map approach: match prefix-list or community, set LocalPref to 250, and apply to the neighbor inbound.

Comparison Table

ConceptLocal PreferenceWeight (brief)
ScopeiBGP (propagated across AS)Local to router only
PurposeControl AS-wide egress selectionControl local router’s selection
Propagated to iBGP peers?YesNo
Default value100vendor-specific (often 0)

Best Practices

  • Use LocalPref to control AS-wide egress preferences instead of configuring weight on every router.
  • Use route-maps for selective, granular control; apply them to neighbor sessions explicitly.
  • Keep LocalPref values consistent in your policy framework (document ranges for local policies).
  • Test on a subset of prefixes before applying broad LocalPref changes.
💡 Věděli jste?Fun fact: Local Preference is only meaningful inside an AS and is ignored by external BGP peers, which is why it’s ideal for expressing internal policy without leaking those preferences outside the AS.
Zaregistruj se pro celé shrnutí
TarjetasTest de conocimientosResumenPodcastMapa mental
Empezar gratis

¿Ya tienes cuenta? Iniciar sesión

BGP Local Preference

Klíčové pojmy: Local Preference controls AS-wide outbound (egress) path selection, LocalPref is a well-known discretionary attribute; default value is 100, LocalPref is advertised to iBGP peers but never sent to eBGP peers, Higher LocalPref value means the route is more preferred, Configure LocalPref globally or per-neighbor using route-maps for selective control, Route-maps must be applied (bound) to the neighbor to take effect, Use LocalPref instead of per-router weight to enforce AS-wide policies, Verify propagation with BGP show commands and check iBGP session states, LocalPref does not affect inbound traffic from other ASes, Document LocalPref value ranges as part of routing policy

## Introduction BGP **Local Preference** (LocalPref) is a key BGP attribute used to control the outbound exit path selection inside a single Autonomous System (AS). It is an attribute exchanged among iBGP peers and allows network operators to express preference for which egress router traffic should use when leaving the AS. > **Definition:** Local Preference is a well-known discretionary BGP attribute that indicates the preferred exit path for routes inside an Autonomous System; higher values are more preferred. ## What Local Preference Controls - Local Preference affects **outbound (egress) path selection** within your AS. It does not influence inbound traffic coming from other ASes. - It is **advertised to all iBGP peers** (internal BGP), so a LocalPref set on one iBGP speaker can propagate to others. - LocalPref **is not sent to eBGP peers** (external BGP). ## Attribute Properties and Defaults - Type: **Well-known discretionary** (must be recognized by all BGP implementations but may be omitted in updates). - Default value: **100** unless configured otherwise. > **Definition:** A well-known discretionary attribute is one that every BGP implementation must recognize, but including it in an update message is optional. ## How Local Preference Is Configured There are two common configuration approaches: 1. Global default: configure a default LocalPref value for the router. Example command on many vendors: `bgp default local-preference <value>` (vendor-specific syntax). 2. Per-neighbor or per-route using route-maps: apply route-maps on BGP neighbors to set LocalPref selectively based on match conditions (prefix, community, AS path, etc.). > **Tip:** Route-maps provide much finer control than changing a global default since you can match specific prefixes or attributes. ### Important operational notes - Because LocalPref is propagated via iBGP, it is a convenient alternative to configuring the proprietary **weight** attribute on every router when you want consistent egress preference across the AS. - Remember to actually apply (bind) the route-map to the neighbor session; creating a route-map alone has no effect until attached to a neighbor or process. ## Practical Examples 1. Simple scenario: Two edge routers R1 and R2 connect to different ISPs. If you want all internal routers to prefer egress via R1, set a higher LocalPref on routes learned from R1. All iBGP peers will then prefer the R1-learned paths. 2. Selective preference using route-map: Match prefixes from a partner or community and set LocalPref to a higher value for those prefixes only. This lets you prefer one ISP for specific destinations while keeping defaults for others. ## Example configuration (conceptual) - Global default approach: set LocalPref to 200 to prefer this router as exit for all received routes. - Route-map approach: match prefix-list or community, set LocalPref to 250, and apply to the neighbor inbound. ## Comparison Table | Concept | Local Preference | Weight (brief) | |---|---:|---| | Scope | iBGP (propagated across AS) | Local to router only | | Purpose | Control AS-wide egress selection | Control local router’s selection | | Propagated to iBGP peers? | Yes | No | | Default value | 100 | vendor-specific (often 0) | ## Best Practices - Use LocalPref to control AS-wide egress preferences instead of configuring weight on every router. - Use route-maps for selective, granular control; apply them to neighbor sessions explicitly. - Keep LocalPref values consistent in your policy framework (document ranges for local policies). - Test on a subset of prefixes before applying broad LocalPref changes. Fun fact: Local Preference is only meaningful inside an AS and is ignored by external BGP peers, which is why it’s ideal for expressing internal policy without leaking those preferences outside the AS.