Post

BGP Attributes - Technical Notes

BGP Attributes - Technical Notes

๐Ÿ“˜ BGP Path Attributes: Comprehensive Technical Notes

Audience: Interviewers โ€ข Network Engineers โ€ข Learners โ€ข Revision Notes
Purpose: A one-stop, technically complete, copyright-free guide to BGP Path Attributes (PAs) for understanding, reviewing, and mastering BGP path selection.


๐Ÿงฉ I. Prerequisites & Overview

Before diving into BGP Path Attributes, ensure the following concepts are clear:

  • BGP Complexity:
    Border Gateway Protocol (BGP) is among the most complex routing protocols used in networking.

  • Routing Basics:
    Understanding of IP packet routing and route advertisement.

  • BGP Peering Knowledge:
    Basic knowledge of EBGP (External BGP) and IBGP (Internal BGP) sessions.

  • IBGP vs. EBGP Behavior:

    • EBGP Update: Routes learned from an external peer can be sent to all other peers.
    • IBGP Update: Routes learned from an internal peer can be advertised to external peers, but not to other internal peers (loop prevention rule).

๐Ÿง  II. What Are Path Attributes (PAs)?

Path Attributes are parameters within a BGP Update message that describe the characteristics of advertised routes.

  • Location:
    Found inside BGP Update messages, which carry new prefixes or withdraw old ones.

  • Structure:
    • Prefixes (routes) sit at the bottom of the update.
    • Path Attributes sit above them, defining properties of those routes.
  • Purpose:
    1. Best Path Selection: Helps BGP decide the most optimal route when multiple paths exist.
    2. Loop Prevention: Detects if a route re-enters the same AS.
    3. Route Classification: Tags routes for filtering, redistribution, or policy decisions (e.g., BGP Communities).
    4. Informative Use: Certain attributes (e.g., Atomic Aggregate) signal route summarization.

๐Ÿงฑ III. Categories of Path Attributes

Each Path Attribute falls into one of four key categories:

CategoryWell-Known/OptionalMandatory/DiscretionaryTransitivityDescription & RuleExamples
Well-Known MandatoryWell-KnownMandatoryAlwaysMust be recognized and included by every BGP device.Next Hop, AS Path, Origin
Well-Known DiscretionaryWell-KnownDiscretionaryAlwaysUnderstood by all BGP routers but optional for use.Local Preference, Atomic Aggregate
Optional TransitiveOptionalDiscretionaryTransitiveMay not be understood; if unknown, still passed along to other ASes.Aggregator, Community
Optional Non-TransitiveOptionalDiscretionaryNon-TransitiveMay not be understood; not shared outside the AS.MED, Originator ID, Cluster List

๐Ÿงฎ IV. BGP Best Path Selection Process (BPSP)

BGP uses a sequential decision algorithm to determine the best route among multiple available ones.
The steps below follow a common mnemonic: N-W-L-O-A-O-M-N-I-O-R-I.

#Attribute / RulePreferenceKey Details
1๏ธโƒฃNext Hop Reachability (N)Must be reachableIf the next hop is unreachable, the route is unusable (remains in the BGP table but not in RIB).
2๏ธโƒฃWeight (W)Highest winsCisco-proprietary; locally significant; not carried in updates (default 0).
3๏ธโƒฃLocal Preference (L)Highest winsInfluences routing inside the AS; default value 100; non-transitive.
4๏ธโƒฃLocally Originated (O)Local routes preferredRoutes injected via network or redistribute commands are preferred.
5๏ธโƒฃAS Path Length (A)Shortest winsFewer AS hops preferred; can be lengthened using AS Path Prepending.
6๏ธโƒฃOrigin Code (O)IGP > IncompleteIGP (i) = from network command; Incomplete (?) = from redistribution.
7๏ธโƒฃMED (M)Lowest winsSuggests preferred entry point into AS; default 0; compared among same external AS.
8๏ธโƒฃEBGP over IBGP (N/E)EBGP preferredExternal paths take precedence over internal.
9๏ธโƒฃIGP Metric (I)Lowest winsApplies to IBGP-learned routes โ€” smaller IGP cost to next hop wins.
๐Ÿ”ŸOldest EBGP Route (O/D)Oldest winsIf multiple EBGP routes exist for the same prefix.
11๏ธโƒฃBGP Router ID (R)Lowest winsUsed as a tie-breaker.
12๏ธโƒฃNeighbor IP AddressLowest winsFinal tie-breaker to ensure deterministic selection.

โš™๏ธ V. Key Path Attributes & Manipulation

๐Ÿ”ธ A. Weight (Cisco Proprietary)

  • Purpose: Influences local path selection (highest wins).
  • Scope: Local to the router; not shared with peers.
  • Example:
    1
    2
    3
    
    route-map SET_WEIGHT permit 10
     set weight 200
    neighbor 10.1.1.2 route-map SET_WEIGHT in
    

๐Ÿ”ธ B. Local Preference

  • Purpose: Controls routing within the AS (highest preferred).
  • Scope: Non-transitive (not advertised to other ASes).
  • Default: 100.
  • Example:
    1
    2
    3
    
    route-map SET_LOCAL_PREF permit 10
     set local-preference 200
    neighbor 10.1.1.2 route-map SET_LOCAL_PREF in
    

๐Ÿ”ธ C. AS Path Prepending

  • Purpose: Artificially lengthen the AS Path to make a route less preferred by external peers.
  • Best Practice: Only prepend your own AS number.
  • Example:
    1
    2
    3
    
    route-map PREPEND-AS permit 10
     set as-path prepend 65001 65001 65001
    neighbor 203.0.113.1 route-map PREPEND-AS out
    

๐Ÿ”ธ D. Multi Exit Discriminator (MED)

  • Purpose: Suggests preferred inbound path for external ASes (lower wins).
  • Default: 0.
  • Comparison: Only compared if routes come from the same external AS (can be overridden).
  • Example:
    1
    2
    3
    
    route-map SET_MED permit 10
     set metric 50
    neighbor 203.0.113.2 route-map SET_MED out
    

E. Origin Code

  • Purpose: Indicates how the route entered BGP.
  • Values:
    • i โ€“ From the network command (IGP-originated).
    • ? โ€“ From redistribution (incomplete). Preference: IGP-originated (i) preferred over incomplete (?).

๐Ÿ”ธ F. BGP Communities

Purpose: Tag routes for policy decisions or filtering. Types: - Standard (16-bit) - Extended (32-bit)

Common Well-Known Communities:

no-advertise โ†’ Do not advertise further. no-export โ†’ Do not advertise outside local AS (IBGP only). local-AS โ†’ Keep route within local AS.

๐Ÿ” VI. Other Essential Concepts

1. Route Policy Application

  • Updating route policies (e.g., route maps) does not immediately affect existing routes in the BGP table.

2. Route Refresh

  • Used to reapply new policies by refreshing route advertisements.
1
2
clear ip bgp * in     # Request inbound updates (refresh inbound)
clear ip bgp * out    # Resend outbound updates (refresh outbound)

3. Redistribution Caution

  • Avoid redistributing BGP routes into IGPs (like OSPF/EIGRP) due to scalability limits โ€” BGP handles far larger routing tables than IGPs.

๐Ÿงพ Summary: Key Takeaways

ConceptPurposeScopePreference Rule
WeightLocal path choiceLocal routerHighest wins
Local PreferenceAS-internal routingWithin ASHighest wins
AS PathLoop prevention / external routingInter-ASShortest wins
Origin CodeRoute source infoInter-ASIGP > Incomplete
MEDExternal entry preferenceBetween ASLowest wins
CommunityRoute classificationLocal/GlobalPolicy dependent

๐Ÿ Final Notes

  • BGP Path Attributes are core to route decision-making in modern networks.
  • Mastery of each attribute โ€” its type, scope, and preference order โ€” is essential for network design, troubleshooting, and optimization.
  • Understanding how PAs interact ensures predictable, policy-driven routing behavior across both internal and external BGP topologies.

๐Ÿ™Œ Connect With Me

GitHub LinkedIn YouTube Gmail

This post is licensed under CC BY 4.0 by the author.