Learn BGP attributes and path selection in detail. Explore AS_PATH, LOCAL_PREF, MED, and more with examples, rules, and benefits for network optimization.
Border Gateway Protocol (BGP) is the routing protocol that holds the internet together. Unlike protocols such as OSPF or EIGRP, which rely on metrics like cost or hop count, BGP makes routing decisions based on a set of attributes. These attributes define how routes are advertised, evaluated, and ultimately selected.
To put it simply: BGP doesn’t just pick the shortest path — it picks the best path according to a hierarchy of rules driven by attributes. Let’s break this down.
What Are BGP Attributes?
Whenever a router advertises a prefix through BGP, it attaches extra details called attributes. Think of them as labels or parameters that describe the path. Other BGP routers use these attributes to compare competing routes and decide which one to prefer.
Attributes are classified into four broad categories:
- Well-Known Mandatory – Must be included in every BGP update.
- Example: AS_PATH, NEXT_HOP, ORIGIN.
- Well-Known Discretionary – Recognized everywhere but not required in updates.
- Example: LOCAL_PREF.
- Optional Transitive – May or may not be present, but if they are, they get passed along across AS boundaries.
- Example: COMMUNITY.
- Optional Non-Transitive – Used locally, discarded outside the AS.
- Example: MULTI_EXIT_DISC (MED).
Key BGP Attributes Explained
Here are the most important attributes that influence path decisions:
- AS_PATH
A record of the AS numbers a route has passed through. Shorter AS_PATHs are preferred. It also prevents routing loops. - NEXT_HOP
Identifies the IP address of the next hop router to reach a destination. Ensures traffic is forwarded correctly. - LOCAL_PREF (Local Preference)
Used within an AS to indicate the preferred exit point. Higher values are favored. This is a critical tool for outbound routing policies. - MED (Multi-Exit Discriminator)
Suggests the preferred entry point into an AS when multiple links exist. Lower MED values are chosen. Typically honored only between neighboring ASes. - ORIGIN
Shows how a route originated:- IGP (from an interior routing protocol) – most preferred.
- EGP (from the old Exterior Gateway Protocol).
- Incomplete (redistributed or unknown) – least preferred.
- COMMUNITY
A tagging mechanism that groups routes for applying common policies. For example, NO_EXPORT prevents a route from leaving the AS. - Weight (Cisco Proprietary)
Used only on Cisco devices. Higher weights win, but the attribute never leaves the local router. Handy for per-router traffic control.
The BGP Path Selection Process
When multiple routes to the same destination are available, BGP follows a fixed decision tree. The commonly used Cisco order is:
- Prefer the path with the highest Weight (local to the router).
- Prefer the highest LOCAL_PREF.
- Prefer routes originated locally.
- Prefer the shortest AS_PATH.
- Prefer the lowest ORIGIN type (IGP > EGP > Incomplete).
- Prefer the lowest MED (only if learned from the same AS).
- Prefer eBGP paths over iBGP paths.
- Prefer the path with the lowest IGP metric to the NEXT_HOP.
- Prefer the oldest path (stability consideration).
- Prefer the path from the lowest BGP router ID.
- If still tied, prefer the lowest neighbor IP address.
Why BGP Path Selection Is Important
- Traffic Engineering – Fine-tune how data exits or enters your network.
- Redundancy – Ensure backup paths are available when a primary fails.
- Load Distribution – Spread traffic across multiple connections.
- Policy Control – Enforce business agreements or optimize costs.
Practical Example
Suppose an enterprise is connected to two ISPs, and both advertise the same prefix (8.8.8.8).

- ISP-1 advertises the route with AS_PATH: 200 300.
- ISP-2 advertises the same route with AS_PATH: 400.
By default, BGP chooses ISP-2 because the AS_PATH is shorter. But if the enterprise applies a higher LOCAL_PREF to ISP-1, traffic will prefer ISP-1 regardless of AS_PATH length.
This illustrates how BGP attributes allow administrators to override default behavior and enforce routing policies.
Final Thoughts
BGP attributes are at the core of how the protocol evaluates and selects paths. By understanding them, network engineers gain powerful control over traffic flows, ensuring reliability, efficiency, and compliance with organizational poli