BGP (Border Gateway Protocol) Introduction — The Routing Protocol of the Internet¶
Border Gateway Protocol (BGP) is the routing protocol that powers the Internet. Unlike routing protocols such as Routing Information Protocol (RIP), Open Shortest Path First (OSPF), and Enhanced Interior Gateway Routing Protocol (EIGRP) that operate within an organisation, BGP is designed to exchange routing information between different organisations, known as Autonomous Systems (AS). Every Internet Service Provider (ISP), major cloud provider, large enterprise, and content delivery network relies on BGP to exchange millions of routes across the global Internet. Understanding BGP is essential for Cloud Architects, Network Engineers, DevOps Engineers, Site Reliability Engineers (SREs), and Platform Engineers working with enterprise networking or cloud connectivity.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand BGP fundamentals
- Learn Autonomous Systems (AS)
- Understand eBGP and iBGP
- Learn BGP path selection
- Understand BGP attributes
- Learn AS Path
- Understand Internet routing
- Explore enterprise and cloud BGP deployments
Prerequisites¶
Complete:
Why Learn BGP?¶
Imagine accessing:
Your request travels through:
- Your ISP
- Regional ISP
- Internet Backbone
- Cloud Provider
- Google's Network
How do thousands of independent networks know where to send your traffic?
The answer is:
What is BGP?¶
Border Gateway Protocol (BGP) is an Exterior Gateway Protocol (EGP) used to exchange routing information between different Autonomous Systems.
Characteristics:
- Internet Routing Protocol
- Policy-Based Routing
- Highly Scalable
- Loop Prevention
- Supports Millions of Routes
Interior vs Exterior Routing¶
Interior Routing:
Exterior Routing:
What is an Autonomous System?¶
An Autonomous System (AS) is a network or group of networks managed by a single administrative organisation with a common routing policy.
Examples:
- Internet Service Providers
- Cloud Providers
- Universities
- Large Enterprises
Each Autonomous System is assigned a unique:
Autonomous System Number (ASN)¶
Example:
Routers use ASNs to identify routing domains.
eBGP¶
External BGP (eBGP) is used between different Autonomous Systems.
Example:
Routes are exchanged across organisational boundaries.
iBGP¶
Internal BGP (iBGP) is used within the same Autonomous System.
Example:
All routers belong to the same ASN.
BGP Neighbors¶
BGP routers establish:
Unlike OSPF, neighbours are manually configured.
Example:
Once connected:
Transport Protocol¶
Unlike most routing protocols:
BGP uses:
Transmission Control Protocol (TCP) provides reliable delivery of routing updates.
Path Vector Protocol¶
BGP is classified as a:
Instead of only selecting the shortest path, BGP evaluates:
- Policies
- Attributes
- AS Paths
- Administrative Preferences
AS Path¶
One of the most important BGP attributes is:
Example:
The AS Path records the sequence of Autonomous Systems a route has traversed.
Benefits:
- Loop Prevention
- Path Selection
Generally, shorter AS paths are preferred, although other attributes may influence the final decision.
BGP Attributes¶
BGP uses multiple attributes to select the best route.
Common attributes include:
- AS Path
- Next Hop
- Local Preference
- Multi-Exit Discriminator (MED)
- Origin
- Weight (Vendor-specific, e.g., Cisco)
Local Preference¶
Used inside an Autonomous System.
Higher Local Preference is preferred.
Example:
Traffic exits through ISP A.
MED (Multi-Exit Discriminator)¶
Used to suggest a preferred entry point into an Autonomous System when multiple links exist.
Lower MED is generally preferred.
Next Hop¶
Every BGP route contains:
The next-hop router must be reachable before the route can be used.
BGP Best Path Selection¶
BGP evaluates multiple attributes before selecting the preferred route.
A simplified decision process includes:
- Highest Weight (vendor-specific)
- Highest Local Preference
- Locally Originated Routes
- Shortest AS Path
- Lowest Origin Type
- Lowest MED
- eBGP over iBGP
- Lowest IGP Cost to Next Hop
The complete algorithm varies slightly by implementation.
Route Advertisement¶
Example:
Cloud Provider:
Advertises:
The enterprise router learns how to reach the cloud network.
Internet Routing Example¶
Every step relies on BGP exchanging routing information between Autonomous Systems.
BGP Workflow¶
Router Starts
↓
TCP Connection
↓
Neighbor Established
↓
Exchange Routes
↓
Apply Policies
↓
Select Best Path
↓
Install Route
↓
Forward Traffic
Enterprise Example¶
Company:
Using BGP:
- Primary ISP
- Backup ISP
- Load Sharing
- Redundant Internet Connectivity
Cloud Perspective¶
BGP is widely used in cloud networking for:
- AWS Direct Connect
- Azure ExpressRoute
- Google Cloud Interconnect
- VPN Gateways
- Hybrid Cloud Connectivity
- Multi-Cloud Routing
BGP enables dynamic route exchange between on-premises and cloud networks.
Kubernetes Perspective¶
Some Kubernetes networking solutions use BGP to advertise:
- Pod Networks
- Service Networks
- Load Balancer IPs
Examples include:
- Calico
- Cilium (optional configurations)
This allows seamless integration with enterprise routing infrastructure.
Linux Perspective¶
Linux supports BGP through routing software such as:
- FRRouting (FRR)
- BIRD
- GoBGP
Display routing table.
Display interfaces.
Routing daemon configuration is handled by the chosen BGP software.
Advantages of BGP¶
- Internet Scale
- Policy-Based Routing
- Highly Scalable
- Supports Redundant Providers
- Loop Prevention
- Flexible Traffic Engineering
Limitations of BGP¶
- Complex Configuration
- Slower Convergence than IGPs
- Policy Management Required
- Requires Careful Planning
- Large Routing Tables
OSPF vs BGP¶
| OSPF | BGP |
|---|---|
| Interior Gateway Protocol | Exterior Gateway Protocol |
| Link-State | Path Vector |
| Cost Metric | Multiple Attributes |
| Enterprise Internal Routing | Internet Routing |
| Fast Convergence | Policy-Based Routing |
Hands-on Lab¶
Task 1¶
Display routing table.
Task 2¶
Research the ASN used by:
- Your ISP
- Amazon
- Microsoft
Task 3¶
Draw:
- Enterprise
- ISP
- Cloud Provider
Show:
- eBGP Sessions
- iBGP Sessions
Task 4¶
Explain:
- eBGP
- iBGP
List five differences.
Task 5¶
Research BGP attributes.
Explain:
- AS Path
- Local Preference
- MED
- Next Hop
Task 6¶
Design a dual-ISP enterprise Internet connection using BGP.
Task 7¶
Explain why BGP uses TCP instead of its own transport protocol.
Task 8¶
Research how AWS Direct Connect, Azure ExpressRoute, or Google Cloud Interconnect uses BGP.
Linux Commands¶
| Command | Purpose |
|---|---|
ip route | Display routing table |
ip addr | Display IP configuration |
ping | Test connectivity |
traceroute | Trace packet path |
Common Mistakes¶
❌ Assuming BGP always selects the shortest AS Path.
✅ Multiple attributes influence route selection.
❌ Confusing iBGP with eBGP.
✅ Remember that iBGP operates within an AS, while eBGP operates between ASes.
❌ Ignoring routing policies.
✅ BGP is policy-driven, not purely shortest-path based.
❌ Expecting BGP to converge as quickly as OSPF.
✅ BGP prioritises scalability and stability over rapid convergence.
❌ Misconfiguring BGP neighbours.
✅ Verify neighbour IPs, ASNs, and TCP connectivity.
Best Practices¶
- Use BGP for Internet and multi-provider connectivity.
- Apply routing policies carefully.
- Filter incoming and outgoing routes appropriately.
- Monitor BGP sessions continuously.
- Document Autonomous System relationships.
- Test failover in dual-ISP environments.
Interview Questions¶
Beginner¶
- What is BGP?
- What is an Autonomous System?
- What is an ASN?
- What port does BGP use?
Intermediate¶
- Compare eBGP and iBGP.
- Explain AS Path.
- What are BGP attributes?
- How does BGP prevent routing loops?
Architect Level¶
- Design a multi-cloud network using BGP.
- How would you implement redundant Internet connectivity with two ISPs?
- Explain BGP best-path selection in a production environment.
Summary¶
In this lesson, you learned:
- BGP fundamentals
- Autonomous Systems
- AS Numbers
- eBGP
- iBGP
- Path Vector routing
- AS Path
- BGP attributes
- Best-path selection
- Enterprise and cloud BGP deployments
BGP is the routing protocol that connects the world's networks. By exchanging routes between Autonomous Systems and applying flexible routing policies, BGP enables reliable, scalable communication across the global Internet while supporting hybrid cloud, multi-cloud, and enterprise connectivity.
Key Takeaways¶
- BGP is an Exterior Gateway Protocol (EGP).
- BGP is a Path Vector Routing Protocol.
- BGP exchanges routes between Autonomous Systems (AS).
- eBGP operates between ASes; iBGP operates within an AS.
- BGP uses TCP Port 179.
- AS Path helps prevent routing loops and influences path selection.
- BGP is the foundation of Internet routing and hybrid cloud connectivity.
What's Next?¶
In the next lesson, you'll learn about Default Routes.
You'll explore:
- What a Default Route is
- Default Gateway vs Default Route
- IPv4 and IPv6 Default Routes
- Route Lookup Process
- Internet Routing
- Static and Dynamic Default Routes
- Enterprise best practices
By the end of the lesson, you'll understand how default routes simplify routing tables and enable devices and routers to reach unknown destinations efficiently.