What is BGP?
Welcome to BGProuting.guru!
This comprehensive tutorial will take you from zero BGP knowledge to expert-level understanding. We'll cover everything from basic concepts to advanced path manipulation, complete with configuration examples and interactive tools.
Border Gateway Protocol (BGP) Overview
BGP is the standardized exterior gateway protocol designed to exchange routing and reachability information between autonomous systems (AS) on the Internet. It's the protocol that makes the Internet work by connecting different networks and ISPs.
Key Characteristics
- Path Vector Protocol: Maintains path information to prevent loops
- Policy-Based Routing: Allows fine-grained control over routing decisions
- Scalability: Designed to handle the global Internet routing table
- Reliability: Uses TCP for reliable transport
- Incremental Updates: Only sends changes, not full tables
- Attribute-Rich: Uses multiple attributes for path selection
Why BGP Matters
BGP is fundamentally different from interior gateway protocols (IGPs) like OSPF or EIGRP. While IGPs focus on finding the shortest path within a single administrative domain, BGP is designed to:
Connect Networks
Enable communication between different autonomous systems, creating the global Internet.
Implement Policy
Enforce routing policies based on business relationships and agreements.
Scale Globally
Handle hundreds of thousands of routes across the entire Internet.
Prevent Loops
Use AS path information to detect and prevent routing loops.
BGP Session Types
Two Main Types
eBGP (External BGP)
Runs between routers in different autonomous systems. Used to exchange routing information between ISPs, enterprises, and other organizations.
iBGP (Internal BGP)
Runs between routers within the same autonomous system. Used to distribute external routing information throughout the AS.
The Internet Ecosystem
To understand BGP, you need to understand how the Internet is structured:
Internet Structure
BGP Message Flow
BGP operates through a series of message exchanges:
- Open: Establishes BGP session between neighbors
- Keepalive: Maintains session and confirms reachability
- Update: Advertises or withdraws routes
- Notification: Reports errors and closes sessions
Basic BGP Configuration Example
Simple eBGP Configuration
# Router A (AS 65001)
router bgp 65001
bgp router-id 1.1.1.1
neighbor 192.168.1.2 remote-as 65002
neighbor 192.168.1.2 description "eBGP to AS 65002"
network 10.1.0.0 mask 255.255.0.0
# Router B (AS 65002)
router bgp 65002
bgp router-id 2.2.2.2
neighbor 192.168.1.1 remote-as 65001
neighbor 192.168.1.1 description "eBGP to AS 65001"
network 10.2.0.0 mask 255.255.0.0
Who Uses BGP?
Internet Service Providers
ISPs use BGP to exchange routing information and connect their networks to the global Internet.
Large Enterprises
Multi-homed organizations use BGP to connect to multiple ISPs for redundancy and load balancing.
Cloud Providers
Cloud platforms use BGP to provide global connectivity and optimal routing for their services.
Important Note
BGP is a complex protocol that requires careful planning and configuration. Misconfigurations can affect Internet routing and cause widespread connectivity issues. Always test BGP configurations in a lab environment before deploying to production.
History & Evolution of BGP
The Evolution of Internet Routing
Understanding BGP's history helps explain why it works the way it does and why certain design decisions were made.
The Need for BGP
In the early days of the Internet (then called ARPANET), routing was simple. As the network grew and became more complex, the need for a scalable inter-domain routing protocol became apparent.
Timeline of BGP Development
Year | Version | RFC | Key Features |
---|---|---|---|
1989 | BGP-1 | RFC 1105 | First version, basic path vector protocol |
1990 | BGP-2 | RFC 1163 | Improved path selection, attribute handling |
1991 | BGP-3 | RFC 1267 | Enhanced error handling, CIDR support |
1994 | BGP-4 | RFC 1771 | Current version, full CIDR support, communities |
2006 | BGP-4+ | RFC 4271 | Updated specification, clarifications |
Why BGP-4 Succeeded
CIDR Support
Full support for Classless Inter-Domain Routing (CIDR) allowed more efficient IP address allocation and reduced routing table size.
Communities
Introduction of BGP communities provided a way to tag routes for policy implementation.
Better Security
Improved path validation and loop prevention mechanisms.
Extensibility
Design allowed for future extensions and new address families.
Problems BGP Solved
Scalability Issues
Previous protocols like EGP couldn't handle the growing Internet. BGP introduced:
- Path Vector Algorithm: Prevented loops while maintaining scalability
- Incremental Updates: Only changes are sent, not full tables
- Policy Support: Administrative control over routing decisions
- Aggregation: Route summarization to reduce table size
BGP Extensions Over Time
Since BGP-4, numerous extensions have been added through additional RFCs:
Extension | RFC | Purpose |
---|---|---|
MP-BGP | RFC 4760 | Multi-protocol support (IPv6, VPN, etc.) |
BGP Communities | RFC 1997 | Route tagging for policy implementation |
Route Refresh | RFC 2918 | Dynamic route table refresh |
BGP Extended Communities | RFC 4360 | Enhanced community support |
BGP Graceful Restart | RFC 4724 | Maintain forwarding during restart |
Modern BGP Challenges
As the Internet has evolved, BGP faces new challenges:
BGP lacks built-in security mechanisms, leading to route hijacking and other attacks.
The global BGP table continues to grow, approaching hardware limits.
Slow convergence can impact Internet stability and performance.
Future of BGP
What's Next?
Several initiatives are working to improve BGP:
- RPKI (Resource Public Key Infrastructure): Cryptographic validation of route announcements
- BGPsec: Path validation using cryptographic signatures
- MANRS (Mutually Agreed Norms for Routing Security): Best practices for routing security
- IPv6 Adoption: Transition to IPv6 and its impact on BGP
Key Milestones
BGP Deployment Milestones
- 1994: BGP-4 becomes the standard
- 1999: First BGP route reflector deployments
- 2003: BGP-4 handles 100,000 routes
- 2010: BGP-4 handles 300,000 routes
- 2014: BGP-4 reaches 500,000 routes
- 2020: BGP-4 approaches 800,000 routes
BGP vs Other Protocols
Understanding Protocol Differences
BGP is fundamentally different from interior gateway protocols. Understanding these differences is crucial for network design and troubleshooting.
Protocol Classification
Routing protocols are classified into two main categories:
Scope: Within a single autonomous system
Goal: Find the shortest/best path
Examples: OSPF, EIGRP, RIP, IS-IS
Metric: Cost, bandwidth, delay
Scope: Between autonomous systems
Goal: Implement policy and prevent loops
Examples: BGP (current), EGP (obsolete)
Metric: Policy-based attributes
Detailed Comparison
Characteristic | BGP | OSPF | EIGRP | RIP |
---|---|---|---|---|
Algorithm Type | Path Vector | Link State | Distance Vector | Distance Vector |
Scope | Inter-AS | Intra-AS | Intra-AS | Intra-AS |
Transport | TCP (179) | IP (89) | IP (88) | UDP (520) |
Convergence | Slow (minutes) | Fast (seconds) | Fast (seconds) | Slow (minutes) |
Scalability | Excellent | Good | Good | Poor |
Policy Support | Extensive | Limited | Limited | None |
Loop Prevention | AS Path | SPF Algorithm | DUAL Algorithm | Split Horizon |
Metric | Multiple Attributes | Cost | Composite | Hop Count |
Authentication | MD5, TCP-AO | Plain, MD5 | MD5, SHA | Plain, MD5 |
Algorithm Comparison
Path Vector vs Link State vs Distance Vector
Information: Complete path to destination
Advantage: Loop prevention, policy control
Disadvantage: Slow convergence
Best for: Inter-domain routing
Information: Complete network topology
Advantage: Fast convergence, loop-free
Disadvantage: High memory/CPU usage
Best for: Large networks
Information: Distance to destination
Advantage: Simple, low resource usage
Disadvantage: Slow convergence, loops
Best for: Small networks
When to Use Each Protocol
Protocol Selection Guidelines
Use BGP When:
- Connecting to the Internet
- Multi-homed to multiple ISPs
- Need policy-based routing
- Large-scale network interconnection
- Service provider network
Use IGP When:
- Single autonomous system
- Need fast convergence
- Internal network routing
- Supporting BGP infrastructure
- Campus/enterprise networks
BGP Unique Features
BGP has several unique features that distinguish it from IGPs:
Rich Attributes
BGP uses multiple attributes (AS path, local preference, MED, etc.) for path selection, allowing complex policy implementation.
Policy Control
Extensive policy mechanisms allow administrators to control routing decisions based on business requirements.
Scalability
Designed to handle hundreds of thousands of routes across the global Internet.
TCP Reliability
Uses TCP for reliable message delivery, ensuring routing information integrity.
Hybrid Deployments
In practice, networks use both BGP and IGPs together:
Typical Enterprise Configuration
# IGP for internal routing
router ospf 1
network 10.0.0.0 0.255.255.255 area 0
network 192.168.1.0 0.0.0.255 area 1
# BGP for external routing
router bgp 65001
bgp router-id 1.1.1.1
neighbor 203.0.113.1 remote-as 65000
neighbor 203.0.113.2 remote-as 65000
redistribute ospf 1
Protocol Interaction
Important Considerations
When running BGP and IGP together:
- Redistribution: Carefully control route redistribution between protocols
- Administrative Distance: BGP (20/200) vs OSPF (110) vs EIGRP (90)
- Synchronization: Ensure IGP carries routes before BGP advertises them
- Route Filtering: Use prefix lists and route maps to control advertisements
Performance Characteristics
Metric | BGP | OSPF | EIGRP | RIP |
---|---|---|---|---|
Convergence Time | 30-180 seconds | 1-5 seconds | 1-3 seconds | 30-180 seconds |
Memory Usage | High | Medium-High | Medium | Low |
CPU Usage | Medium | High (during SPF) | Low-Medium | Low |
Network Overhead | Low | Medium | Low | High |
Key BGP Terminology
Essential BGP Vocabulary
Understanding BGP terminology is crucial for effective communication and troubleshooting. This section covers the most important terms you'll encounter.
Core Concepts
Autonomous System (AS)
A collection of IP networks under a single technical administration, using an interior gateway protocol and common routing policy.
Example: AS 65001, AS 7018 (AT&T)
AS Path
The sequence of autonomous systems that a route has traversed. Used for loop prevention and path selection.
Example: 65001 65002 65003
BGP Speaker
A router that implements BGP and can exchange routing information with other BGP speakers.
Types: eBGP speaker, iBGP speaker
BGP Peer/Neighbor
Two BGP speakers that have established a BGP session and exchange routing information.
Types: eBGP peer, iBGP peer
Session Types
BGP Session Classification
External BGP (eBGP)
- Between different autonomous systems
- Administrative distance: 20
- TTL typically 1 (directly connected)
- Next-hop usually changed
Internal BGP (iBGP)
- Within the same autonomous system
- Administrative distance: 200
- TTL typically 255 (may be multi-hop)
- Next-hop typically preserved
BGP Attributes
BGP uses attributes to describe route characteristics and make path selection decisions:
Attribute | Type | Description | Usage |
---|---|---|---|
AS Path | Well-known Mandatory | Sequence of ASes the route has traversed | Loop prevention, path selection |
Next Hop | Well-known Mandatory | IP address of next router to reach destination | Packet forwarding |
Origin | Well-known Mandatory | How the route was introduced to BGP | Path selection (IGP > EGP > Incomplete) |
Local Preference | Well-known Discretionary | Local AS preference for outbound traffic | Outbound traffic engineering |
MED | Optional Non-transitive | Multi-Exit Discriminator for inbound traffic | Inbound traffic engineering |
Community | Optional Transitive | Route tagging for policy implementation | Policy control, route filtering |
BGP States
BGP sessions progress through several states:
State | Description | Actions |
---|---|---|
Idle | Initial state, no connection | Wait for start event |
Connect | Attempting TCP connection | TCP connection in progress |
Active | TCP connection failed, retrying | Retry TCP connection |
OpenSent | TCP connected, Open message sent | Wait for Open message |
OpenConfirm | Open message received, Keepalive sent | Wait for Keepalive |
Established | Session established, exchanging routes | Route exchange and maintenance |
Route Types
The route selected by BGP's path selection algorithm as the best path to a destination.
Status: Installed in routing table
Alternative paths to the same destination, kept in BGP table but not used for forwarding.
Status: Available for failover
Routes that are not advertised due to dampening or policy restrictions.
Status: Not available for use
Policy Terms
Route Filtering
Controlling which routes are accepted, advertised, or processed using prefix lists, route maps, or AS path filters.
Route Map
A policy tool that allows conditional route processing, attribute modification, and filtering.
Prefix List
A filter that matches routes based on network prefix and mask length.
Community
A 32-bit value attached to routes for policy implementation and route tagging.
Advanced Concepts
Advanced BGP Features
Route Reflector
A BGP speaker that reflects routes from one iBGP peer to another, reducing the need for full mesh iBGP.
Confederation
A method to divide a large AS into smaller sub-ASes for better scalability and management.
Route Dampening
A mechanism to suppress unstable routes that frequently change state (flap).
Multihoming
Connecting to multiple ISPs for redundancy and load balancing.
Common Acronyms
Acronym | Full Form | Description |
---|---|---|
AS | Autonomous System | Administrative domain with unified routing policy |
MED | Multi-Exit Discriminator | Metric for inbound traffic engineering |
RIB | Routing Information Base | BGP routing table |
FIB | Forwarding Information Base | Active routing table used for forwarding |
NLRI | Network Layer Reachability Information | Routing information in BGP updates |
AFI | Address Family Identifier | Identifies the network layer protocol |
SAFI | Subsequent Address Family Identifier | Provides additional context for AFI |