BGP path attributes
The path attributes carried in BGP UPDATE messages — classification, encoding, and per-attribute semantics.
Contents
Attribute classification
Path attributes fall into four categories based on two flag bits:
| Category | Recognition | Propagation | Example |
|---|---|---|---|
| Well-known mandatory | All implementations | Always forwarded | ORIGIN, AS_PATH, NEXT_HOP |
| Well-known discretionary | All implementations | Forwarded if present | LOCAL_PREF, ATOMIC_AGGREGATE |
| Optional transitive | May not be recognized | Forwarded with Partial bit set | AGGREGATOR, COMMUNITIES |
| Optional non-transitive | May not be recognized | Silently dropped | MULTI_EXIT_DISC |
Attribute encoding
Each attribute is a TLV triplet: Attribute Flags (1 octet) + Type Code (1 octet) + Length (1 or 2 octets) + Value.
| Flag bit | Position | Meaning when set |
|---|---|---|
| Optional | bit 0 | Attribute is optional (not well-known) |
| Transitive | bit 1 | Optional attribute is passed to peers |
| Partial | bit 2 | Attribute was not recognized by some AS in the path |
| Extended Length | bit 3 | Length field is 2 octets instead of 1 |
Attributes within an UPDATE are ordered by Type Code (ascending). A receiver handles out-of-order attributes. Duplicate Type Codes in the same UPDATE are an error.
ORIGIN (Type 1)
Well-known mandatory. Indicates how the route was injected into BGP.
| Value | Meaning | Preference |
|---|---|---|
| 0 | IGP — originated from an interior protocol (network statement) | Highest |
| 1 | EGP — learned via the legacy Exterior Gateway Protocol | Middle |
| 2 | INCOMPLETE — redistributed from another source | Lowest |
The Decision Process prefers lower ORIGIN values. A route redistributed from OSPF gets INCOMPLETE; a route originated via network or aggregate-address gets IGP.
AS_PATH (Type 2)
Well-known mandatory. Records the sequence of ASes the route has traversed. Provides loop detection — a router rejects routes containing its own ASN.
Segment types
| Type | Name | Meaning |
|---|---|---|
| 1 | AS_SET | Unordered set (result of aggregation) |
| 2 | AS_SEQUENCE | Ordered list of ASes traversed |
Each segment is encoded as: segment type (1 octet) + count (1 octet, number of AS numbers) + AS numbers (2 octets each, or 4 octets with RFC 6793).
Prepending rules
When originating a route to EBGP: single-element AS_SEQUENCE with own ASN. To IBGP: empty AS_PATH.
An AS_SET counts as path length 1 regardless of how many ASes it contains. RFC 9774 deprecates AS_SET and AS_CONFED_SET — new implementations reject routes containing them.
NEXT_HOP (Type 3)
Well-known mandatory. The IPv4 address of the router to use as next hop toward the advertised destinations.
NEXT_HOP rules
| Scenario | NEXT_HOP value |
|---|---|
| EBGP, directly connected | Sender’s interface address facing the peer |
| EBGP, multihop | Sender’s session source address (default) |
| IBGP, externally learned | Preserved from EBGP peer (default) |
| IBGP, locally originated | Interface through which the network is reachable |
| next-hop-self configured | Sender’s own address regardless of source |
The receiving router resolves NEXT_HOP recursively through the routing table to determine the actual forwarding interface. If unresolvable, the route is ineligible for selection.
MULTI_EXIT_DISC (Type 4)
Optional non-transitive. A 4-octet metric used to influence inbound traffic when multiple links connect to the same neighbor AS. Lower is preferred.
Key constraints:
- Comparable only between routes from the same neighbor AS
- Received over EBGP, may be propagated over IBGP within the same AS
- Never propagated to other external ASes
- Must be removed or evaluated before the Decision Process
LOCAL_PREF (Type 5)
Well-known discretionary. A 4-octet unsigned integer expressing the local AS’s degree of preference for a route. Higher is preferred.
| Context | Behavior |
|---|---|
| Sent to IBGP peer | Required in all UPDATEs |
| Sent to EBGP peer | Never included (except confederations) |
| Received from EBGP | Ignored (except confederations) |
LOCAL_PREF is the first discriminator in the Decision Process after policy filtering.
ATOMIC_AGGREGATE (Type 6)
Well-known discretionary. Zero-length attribute. Signals that the originator selected a less-specific route and dropped some AS_PATH information (AS_SET) during aggregation.
A receiver of ATOMIC_AGGREGATE must not deaggregate the prefix into more-specifics. The actual forwarding path may differ from what AS_PATH shows.
AGGREGATOR (Type 7)
Optional transitive. Carries the AS number (2 octets) and BGP Identifier (4 octets) of the router that formed the aggregate. Added during aggregation to preserve attribution.
Attribute summary table
| Type | Name | Category | Length | Decision Process role |
|---|---|---|---|---|
| 1 | ORIGIN | WK mandatory | 1 octet | Tie-break step 2 |
| 2 | AS_PATH | WK mandatory | variable | Tie-break step 1 (shortest path) |
| 3 | NEXT_HOP | WK mandatory | 4 octets | Resolvability check, IGP cost |
| 4 | MULTI_EXIT_DISC | Opt non-transitive | 4 octets | Tie-break step 3 (same neighbor AS) |
| 5 | LOCAL_PREF | WK discretionary | 4 octets | Primary selection (highest wins) |
| 6 | ATOMIC_AGGREGATE | WK discretionary | 0 | Informational |
| 7 | AGGREGATOR | Opt transitive | 6 octets | Informational |