BGP
Related links to learn BGP
Here is the markdown summary of the video without timestamps:
What is BGP?
- Overview: Border Gateway Protocol (BGP) is the primary routing protocol deployed across the internet for exchanging reachability information. Unlike protocols like OSPF or EIGRP, BGP does not use a simple metric (such as shortest path) to determine the best route.
- Scalability & Autonomous Systems (AS):
- To handle the massive scale of the internet, BGP divides it into Autonomous Systems (AS)—independently managed networks (like ISPs or large enterprises) assigned unique AS numbers.
Each AS contains routers, servers, and end-user devices.
Path Vector Protocol:
- BGP determines routing paths by creating an AS Path, which is a sequenced list of AS numbers that packets must traverse to reach a destination network.
- Routers store these routes inside a BGP table.
BPG table:
Network: * > 20.20.20.0/24
Next Hop: 127.52.2.1
Metric: 0
LocPfr:
Weight:
Path:
- BGP vs. IGP:
- BGP handles inter-AS routing (between different Autonomous Systems).
Interior Gateway Protocols (IGPs) like OSPF, IS-IS, and EIGRP handle intra-AS routing (within a single Autonomous System).
Path Selection & Attributes:
- The best path on the internet is rarely just the physical shortest path.
- Routing decisions account for business agreements, transit costs, and geographical policies using configurable BGP attributes.
eBGP vs iBGP - What's the difference?
- Overview: eBGP (External BGP) and iBGP (Internal BGP) are not two different protocols, but rather two different manifestations of the exact same Border Gateway Protocol operating under different peering scenarios.
- Peering Definitions:
- eBGP: Established between BGP routers located in different Autonomous Systems (inter-AS).
iBGP: Established between BGP routers located in the same Autonomous System (intra-AS).
Implementation Rules:
- Full Mesh Requirement: iBGP requires a full-mesh peering arrangement where every iBGP speaker within an AS must peer with every other iBGP speaker. eBGP has no such requirement.
Direct Connection: eBGP peers typically need to be directly connected by default, whereas iBGP peers can be multiple hops away (as long as an IGP or static routing provides underlying connectivity).
Route Handling & Differences:
- Administrative Distance (AD): eBGP routes have a default AD of 20 (more trustworthy), while iBGP routes have a default AD of 200.
- Next-Hop Behavior: When advertising to an eBGP peer, the next-hop IP is changed to the interface used to reach that peer. When advertising via iBGP, the next-hop attribute typically remains unchanged.
- AS Path Manipulation: eBGP prepends its local AS number to the AS path when advertising routes outward. iBGP leaves the AS path unchanged when passing updates internally.
Example of eBGP:
router bgp 100 neighbor 192.0.2.2 remote-as 190
router bgp 190 neighbor 192.0.2.1 remote-as 100
Example of iBGP:
router bgp 100 neighbor 203.0.113.1 remote-as 100
router bgp 100 neighbor 203.0.113.2 remote-as 100
BGP Attributes and Determining the Best Path
- Overview: When BGP routers receive multiple paths to the same destination network, they evaluate them by comparing a series of attributes in a strict sequential order until a tie-breaker is reached.
- Path Selection Logic:
Paths are compared attribute by attribute. If a path is preferred, it wins; if there is a tie, the process moves down the sequence to the next attribute until the best path is chosen and installed in the routing table.
BGP Best Path Selection Sequence (Common Order):
- Weight: Cisco-proprietary attribute (highest wins).
- Local Preference: Preferred outbound path within the local AS (highest wins).
- Locally Originated: Routes created by the local router preferred over external.
- AS-Path Length: Shortest AS path is preferred (fewest ASNs wins).
- Origin Code: IGP preferred over EGP, which is preferred over Incomplete.
- Multi-Exit Discriminator (MED): Ingress path preference into an AS (lowest wins).
- eBGP over iBGP: eBGP paths preferred over iBGP paths.
- IGP Metric to Next Hop: Shortest interior metric to the BGP next hop.
- Oldest Path: For eBGP paths, the oldest (stable) route is preferred.
- Router ID: Lowest neighbor/originator router ID.
Why does BGP require an IGP to function?
- Overview: A fundamental prerequisite for deploying BGP is that internal routing must already be fully established within an Autonomous System using an Interior Gateway Protocol (IGP) like OSPF/EIGRP or static routing.
- Why BGP Needs an IGP:
- iBGP Full-Mesh Requirement: iBGP requires a full-mesh peering arrangement among all internal BGP routers within an AS. For these routers to establish and maintain TCP connections with each other, underlying reachability must already exist.
- Division of Responsibility:
- BGP (eBGP & iBGP): Responsible for learning and propagating routes external to the local AS. BGP is not designed or optimized for advertising internal routes within an AS.
IGP: Responsible for handling all routing internal to the local AS (making sure internal routers can reach each other).
Best Practice: While BGP can technically be configured to advertise internal routes, it is inefficient, slower to converge than IGPs, and generally considered bad practice.