Well-Known BGP Attributes
Essential Path Information
Well-known attributes are mandatory or discretionary attributes that all BGP implementations must recognize. They provide essential information for path selection and routing.
Attribute Classification
BGP attributes are classified into four categories based on their properties:
Category | Recognition | Propagation | Required |
---|---|---|---|
Well-known Mandatory | All BGP speakers | All peers | Yes |
Well-known Discretionary | All BGP speakers | All peers | No |
Optional Transitive | Some BGP speakers | All peers | No |
Optional Non-transitive | Some BGP speakers | eBGP only | No |
Well-Known Mandatory Attributes
These attributes must be present in every BGP update message:
1. ORIGIN Attribute (Type Code 1)
Purpose: Indicates how the route was introduced into BGP
Length: 1 byte
Values:
- 0 (IGP): Route learned from interior gateway protocol
- 1 (EGP): Route learned from Exterior Gateway Protocol
- 2 (INCOMPLETE): Route learned by other means (redistribution)
Path Selection: IGP > EGP > INCOMPLETE
ORIGIN Attribute Configuration
# Network statement (IGP origin)
router bgp 65001
network 192.168.1.0 mask 255.255.255.0
# Redistribution (INCOMPLETE origin)
router bgp 65001
redistribute ospf 1
# Route map to set origin
route-map SET-ORIGIN permit 10
set origin igp
2. AS_PATH Attribute (Type Code 2)
Purpose: Lists the autonomous systems that the route has traversed
Length: Variable
Format: Sequence of AS numbers
Functions:
- Loop prevention (reject if local AS in path)
- Path selection (shorter path preferred)
- Policy implementation (AS-based filtering)
AS_PATH Examples
- Empty: Route originated locally
- 65001: Route from AS 65001
- 65001 65002: Route traversed AS 65001 and 65002
- 65001 65002 65003: Route traversed three ASes
3. NEXT_HOP Attribute (Type Code 3)
Purpose: Specifies the next hop IP address for the route
Length: 4 bytes (IPv4 address)
Behavior:
- eBGP: Next hop is set to advertising router's IP
- iBGP: Next hop is preserved from eBGP
- Next-hop-self: Override next hop to local router
Next Hop Configuration
# Set next hop to self for iBGP
router bgp 65001
neighbor 192.168.1.2 remote-as 65001
neighbor 192.168.1.2 next-hop-self
# Route map to set next hop
route-map SET-NEXTHOP permit 10
set ip next-hop 192.168.1.1
Well-Known Discretionary Attributes
These attributes are recognized by all BGP speakers but are not required:
4. LOCAL_PREF Attribute (Type Code 5)
Purpose: Indicates local preference for outbound traffic
Length: 4 bytes
Scope: Local AS only (not sent to eBGP peers)
Default: 100
Selection: Higher values preferred
Use Cases:
- Primary/backup link selection
- Traffic engineering
- ISP preference
LOCAL_PREF Configuration
# Set default local preference
router bgp 65001
bgp default local-preference 200
# Route map to set local preference
route-map SET-LOCAL-PREF permit 10
set local-preference 150
# Apply to neighbor
router bgp 65001
neighbor 192.168.1.2 route-map SET-LOCAL-PREF in
5. ATOMIC_AGGREGATE Attribute (Type Code 6)
Purpose: Indicates route aggregation has occurred
Length: 0 bytes (flag only)
Meaning: Some routing information has been lost due to aggregation
Usage:
- Set when routes are aggregated
- Indicates potential routing loops
- Warns of information loss
Attribute Processing Rules
Well-Known Attribute Processing
- Mandatory Check: Verify mandatory attributes are present
- Format Validation: Check attribute format and length
- Value Validation: Validate attribute values
- Path Selection: Use attributes in path selection algorithm
- Policy Application: Apply routing policies
- Propagation: Forward attributes to appropriate peers
Attribute Flags
Each attribute has flags that define its properties:
Attribute | Optional | Transitive | Partial | Extended |
---|---|---|---|---|
ORIGIN | 0 | 1 | 0 | 0 |
AS_PATH | 0 | 1 | 0 | 0 |
NEXT_HOP | 0 | 1 | 0 | 0 |
LOCAL_PREF | 0 | 1 | 0 | 0 |
ATOMIC_AGGREGATE | 0 | 1 | 0 | 0 |
Attribute Manipulation
Well-known attributes can be modified using route maps:
Comprehensive Attribute Configuration
# Route map to modify multiple attributes
route-map MODIFY-ATTRIBUTES permit 10
match ip address prefix-list CUSTOMER-ROUTES
set origin igp
set local-preference 150
set as-path prepend 65001 65001
route-map MODIFY-ATTRIBUTES permit 20
set local-preference 100
# Apply to neighbor
router bgp 65001
neighbor 192.168.1.2 route-map MODIFY-ATTRIBUTES in
Common Attribute Scenarios
Primary/Backup Links
Use LOCAL_PREF to prefer primary ISP over backup ISP.
route-map PRIMARY-ISP permit 10
set local-preference 200
route-map BACKUP-ISP permit 10
set local-preference 100
Traffic Engineering
Use AS_PATH prepending to influence inbound traffic.
route-map PREPEND-PATH permit 10
set as-path prepend 65001 65001 65001
Attribute Validation
Attribute Validation Rules
BGP speakers must validate well-known attributes:
- Presence: Mandatory attributes must be present
- Format: Attributes must have correct format
- Length: Attribute length must be valid
- Values: Attribute values must be in valid range
- Consistency: Attributes must be mutually consistent
Troubleshooting Attribute Issues
Attribute Debugging Commands
# Show BGP table with attributes
show ip bgp 192.168.1.0/24
# Show detailed path information
show ip bgp 192.168.1.0/24 longer-prefixes
# Show attributes for specific neighbor
show ip bgp neighbor 192.168.1.2 received-routes
# Debug attribute processing
debug ip bgp updates
Attribute Display Example
BGP Table Output
BGP table version is 15, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 192.168.1.0/24 192.168.1.2 0 100 0 65002 i
* 192.168.1.0/24 192.168.1.3 0 80 0 65003 65002 i
Path details:
Path 1: Origin IGP, Local Preference 100, AS Path: 65002
Path 2: Origin IGP, Local Preference 80, AS Path: 65003 65002
Best Practices
Well-Known Attribute Best Practices
- Consistent Policies: Apply consistent attribute policies
- Documentation: Document attribute manipulation policies
- Monitoring: Monitor attribute changes and their effects
- Testing: Test attribute changes in lab environment
- Validation: Validate attribute configurations
Attribute Security
Security Considerations
Protecting against attribute manipulation:
- Input Validation: Validate received attributes
- Filtering: Filter attributes based on policies
- Monitoring: Monitor for unusual attribute values
- Authentication: Use BGP authentication
Optional BGP Attributes
Extended Path Information
Optional attributes provide additional path information for advanced routing policies and traffic engineering. They may be transitive or non-transitive.
Optional Attribute Types
Optional attributes are divided into two categories:
Recognition: May not be recognized by all speakers
Propagation: Passed to all BGP peers
Partial Flag: Set if not recognized
Examples: AGGREGATOR, COMMUNITY
Recognition: May not be recognized by all speakers
Propagation: Not passed to eBGP peers
Partial Flag: Not applicable
Examples: MED, ORIGINATOR_ID
Multi-Exit Discriminator (MED) - Type Code 4
Type: Optional Non-transitive
Purpose: Influence inbound traffic from neighboring AS
Length: 4 bytes
Default: 0
Selection: Lower values preferred
Scope: Between directly connected ASes only
Also Known As: Inter-AS metric
MED Usage Guidelines
MED is used to influence how neighboring AS selects entry points:
- Hot Potato Routing: Suggest preferred entry point
- Load Balancing: Distribute traffic across links
- Cost Optimization: Direct traffic to lower-cost paths
- Capacity Management: Manage link utilization
MED Configuration Examples
# Set MED for outbound routes
route-map SET-MED-PRIMARY permit 10
set metric 100
route-map SET-MED-BACKUP permit 10
set metric 200
# Apply to neighbors
router bgp 65001
neighbor 192.168.1.2 route-map SET-MED-PRIMARY out
neighbor 192.168.1.3 route-map SET-MED-BACKUP out
# Always compare MED
router bgp 65001
bgp always-compare-med
COMMUNITY Attribute - Type Code 8
Type: Optional Transitive
Purpose: Route tagging for policy implementation
Length: Variable (multiple 4-byte values)
Format: 16-bit AS number : 16-bit value
Usage: Flexible policy implementation
Well-Known Communities
Standard Well-Known Communities
- NO_EXPORT (65535:65281): Do not advertise to eBGP peers
- NO_ADVERTISE (65535:65282): Do not advertise to any peer
- LOCAL_AS (65535:65283): Do not advertise outside local AS
- NOPEER (65535:65284): Do not advertise to peer AS
Community Configuration
# Define community list
ip community-list standard CUSTOMER permit 65001:100
ip community-list standard PEER permit 65001:200
ip community-list standard TRANSIT permit 65001:300
# Set communities with route map
route-map SET-COMMUNITY permit 10
match ip address prefix-list CUSTOMER-ROUTES
set community 65001:100
set community no-export additive
# Apply communities
router bgp 65001
neighbor 192.168.1.2 send-community
neighbor 192.168.1.2 route-map SET-COMMUNITY out
BGP Path Selection Process
The Heart of BGP Decision Making
BGP uses a complex algorithm to select the best path among multiple routes to the same destination. Understanding this process is crucial for network design and troubleshooting.
Path Selection Overview
When BGP receives multiple routes to the same destination, it uses a step-by-step process to select the best path. The process stops at the first step that produces a clear winner.
Key Principles
- Deterministic: Same input always produces same output
- Sequential: Steps are evaluated in specific order
- Configurable: Some steps can be modified by configuration
- Vendor-Specific: Later steps may vary by vendor
BGP Path Selection Algorithm
The standard BGP path selection process follows these steps:
Step | Attribute | Preference | Scope | Description |
---|---|---|---|---|
1 | Valid Route | Valid routes only | Local | Reject invalid routes |
2 | Weight | Higher | Local router | Cisco-specific attribute |
3 | Local Preference | Higher | Local AS | Outbound traffic preference |
4 | Locally Originated | Local routes | Local router | Network/redistribute/aggregate |
5 | AS Path Length | Shorter | Global | Hop count in AS path |
6 | Origin | IGP > EGP > Incomplete | Global | Route origin type |
7 | MED | Lower | Between ASes | Multi-exit discriminator |
8 | Path Type | eBGP > iBGP | Local AS | External vs internal |
9 | IGP Metric | Lower | Local AS | Cost to next hop |
10 | Multipath | Load balance | Local router | Equal cost paths |
11 | Age | Oldest | Local router | Route stability |
12 | Router ID | Lower | Local router | Tie-breaker |
13 | Peer IP | Lower | Local router | Final tie-breaker |
Path Selection Example
Example Scenario
Routes to 192.168.1.0/24:
Path A: Local Pref=100, AS Path=65002, MED=50, eBGP
Path B: Local Pref=200, AS Path=65003 65004, MED=100, eBGP
Path C: Local Pref=100, AS Path=65002, MED=75, iBGP
Selection Process:
1. All paths valid ✓
2. No weight differences
3. Path B wins (Local Pref=200 > 100)
Selected Path: Path B
Local Preference
Outbound Traffic Engineering
Local Preference is one of the most important BGP attributes for controlling outbound traffic flow within an autonomous system. It's the primary tool for traffic engineering in BGP.
Local Preference Overview
Local Preference (LOCAL_PREF) is a well-known discretionary attribute that indicates to other BGP speakers within the same AS which path is preferred for outbound traffic.
- Type: Well-known discretionary
- Length: 4 bytes
- Default: 100
- Range: 0-4294967295
- Scope: Local AS only
- Preference: Higher values preferred
- eBGP: Not sent to external peers
- iBGP: Propagated to internal peers
- Path Selection: Step 3 in decision process
- Overrides: AS path length and origin
- Modification: Via route maps
Setting Local Preference
Route Map Configuration
# Create route map to set local preference
route-map SET-LOCAL-PREF permit 10
match ip address prefix-list PRIMARY-ROUTES
set local-preference 200
route-map SET-LOCAL-PREF permit 20
match ip address prefix-list BACKUP-ROUTES
set local-preference 50
route-map SET-LOCAL-PREF permit 30
set local-preference 100
# Apply to neighbor
router bgp 65001
neighbor 192.168.1.2 route-map SET-LOCAL-PREF in
Common Local Preference Scenarios
Primary/Backup Links
Primary/Backup Configuration
Primary/Backup Configuration
# Primary ISP (higher local preference)
route-map PRIMARY-ISP permit 10
set local-preference 200
# Backup ISP (lower local preference)
route-map BACKUP-ISP permit 10
set local-preference 100
# Apply to neighbors
router bgp 65001
neighbor 192.168.1.2 remote-as 65002
neighbor 192.168.1.2 route-map PRIMARY-ISP in
neighbor 192.168.1.3 remote-as 65003
neighbor 192.168.1.3 route-map BACKUP-ISP in
BGP Communities
Route Tagging and Policy Implementation
BGP Communities provide a flexible mechanism for route tagging and policy implementation. They enable granular control over routing decisions and traffic engineering.
Community Overview
BGP Communities are optional transitive attributes that can be attached to routes to implement routing policies. They act as "tags" that can be used to group routes and apply consistent policies.
- Type: Optional Transitive
- Length: 4 bytes per community
- Format: 16-bit AS : 16-bit value
- Multiple: Multiple communities per route
- Propagation: Across all BGP speakers
- Route Classification: Group similar routes
- Policy Implementation: Apply policies to groups
- Traffic Engineering: Control path selection
- Filtering: Control route advertisement
- Documentation: Self-documenting policies
Well-Known Communities
Standard Well-Known Communities
Behavior: Do not advertise to eBGP peers
Usage: Keep routes within confederation
Example: Internal-only routes
Behavior: Do not advertise to any peer
Usage: Completely suppress route
Example: Debugging purposes
Community Configuration
# Enable community sending
router bgp 65001
neighbor 192.168.1.2 send-community
# Set community with route map
route-map SET-COMMUNITY permit 10
match ip address prefix-list CUSTOMER-ROUTES
set community 65001:100
# Set multiple communities
route-map SET-COMMUNITY permit 20
match ip address prefix-list PEER-ROUTES
set community 65001:200 65001:300
# Add communities (preserving existing)
route-map ADD-COMMUNITY permit 10
set community 65001:400 additive
Business Relationship Classification
Relationship | Community | Local Preference | Usage |
---|---|---|---|
Customer | 65001:100 | 300 | Revenue-generating routes |
Peer | 65001:200 | 200 | Settlement-free routes |
Transit | 65001:300 | 100 | Paid transit routes |
Backup | 65001:400 | 50 | Emergency paths |