Networking - BGP (Border Gateway Protocol
What is BGP?
BGP (Border Gateway Protocol) is the protocol that controls how data is routed between different autonomous systems (AS) on the internet.
-
An Autonomous System (AS) is a collection of IP networks under a single organization or administrative domain.
-
BGP is often called the “Internet’s routing protocol” because it decides the best paths for data to travel across the global internet.
Why BGP is Important
-
The internet is made of thousands of networks (ISPs, companies, universities).
-
BGP ensures that data finds the most efficient and reliable path between these networks.
-
It prevents routing loops and enables redundancy.
How BGP Works
-
Exchanging Routing Information:
-
BGP routers share their network routes with neighboring BGP routers.
-
Each router maintains a routing table with the best path to each network.
-
-
Path Selection:
BGP chooses the path based on multiple factors:-
AS Path → Prefer shorter sequences of AS hops.
-
Policies → Administrative preferences (business agreements, costs).
-
Other attributes → Local preference, MED (Multi-Exit Discriminator), etc.
-
-
Updating Routes:
-
BGP updates only when there’s a change (path added/removed).
-
Uses TCP (port 179) for reliable communication between BGP peers.
-
Types of BGP
-
External BGP (eBGP)
-
Between routers of different autonomous systems.
-
Example: ISP A ↔ ISP B.
-
-
Internal BGP (iBGP)
-
Between routers inside the same AS.
-
Ensures all internal routers know about external routes.
-
Features of BGP
-
Scalable → Handles thousands of routes on the internet.
-
Policy-based routing → Allows administrative control over routing.
-
Loop Prevention → Tracks AS paths to avoid routing loops.
Real-Life Example
-
When you visit a website hosted in another country:
-
Your ISP uses BGP to determine the best path through multiple networks to reach the web server.
-
Key Point
BGP doesn’t care about speed or latency directly — it primarily focuses on policy and reachability.
Other protocols (like OSPF, EIGRP) handle routing inside a network, but BGP handles routing between networks (the internet).
In short: BGP is like the GPS for the internet.
-
Each network (AS) tells its neighbors which roads (routes) it can take.
-
BGP decides the “best” path for your data to reach its destination, even across continents.