Skip to content
Learni
View all tutorials
Réseaux

How to Understand BGP in 2026: Beginner's Guide

Lire en français

Introduction

BGP, or Border Gateway Protocol, is the dynamic routing protocol that keeps the Internet running. Unlike internal protocols like OSPF or RIP, which handle routing within a single autonomous system (AS), BGP operates between ASes to connect the entire world. Picture the Internet as a network of independent cities: BGP is the signpost system that chooses optimal paths between them, considering not just distance but also economic policies, security, and reliability.

Why is BGP crucial in 2026? With the rise of hybrid clouds, global data centers, and sophisticated DDoS attacks, understanding BGP helps prevent worldwide outages like the 2021 Fastly incident. This beginner's guide, 100% conceptual, takes you from basics to theoretical mastery: sessions, attributes, selection algorithm. No code—just clear analogies and concrete examples so you can bookmark this as a go-to reference. By the end, you'll be able to explain BGP to a colleague in 5 minutes. (248 words)

Prerequisites

  • Basic knowledge of IP addresses and subnet masks.
  • Understanding of static vs. dynamic routing (e.g., OSPF for intra-AS).
  • Familiarity with Autonomous Systems (AS): an AS is a group of networks under single administration, identified by a unique number (ASN, like 15169 for Google).

What is BGP and Its Core Role?

BGP is a path-vector routing protocol, version 4 (RFC 4271), that exchanges reachability information between ASes. Unlike OSPF (link-state) or RIP (distance-vector), BGP doesn't automatically compute shortest paths: it propagates IP prefixes (e.g., 192.0.2.0/24) with full paths (AS_PATH).

Analogy: Think of BGP as an intercontinental travel guide. Instead of saying "Paris is 1,000 km away," it lists "Paris via Madrid (AS-Spain) then Lisbon (AS-Portugal)." This prevents loops (via AS_PATH) and enables policy application.

Real-world example: Your ISP (AS-ISP) uses BGP to learn that google.com (AS15169) is reachable via an upstream peer (AS-Transit). Without BGP, the Internet would collapse into isolated silos. BGP supports up to 4.29 billion IPv4/IPv6 addresses and handles 900,000+ prefixes in global tables (2026 estimates from Hurricane Electric).

BGP is external by default (eBGP) but can be internal (iBGP). It uses TCP port 179 for reliable sessions, unlike UDP for OSPF.

The Two Types of BGP Sessions: iBGP and eBGP

eBGP (External BGP): Between different ASes. TTL=1 by default (direct neighbors), AS_PATH prepended at origin. E.g., your enterprise AS peering with ISP AS.

iBGP (Internal BGP): Within the same AS. TTL=255 (IGP routing possible), no AS_PATH prepending. Requires full-mesh or route reflectors to prevent loops.

Analogy: eBGP is like an international call (AS borders), iBGP is like internal company walkie-talkies.

Example: In large AS-Grand (routers R1, R2, R3), R1 learns 10.0.0.0/8 via eBGP and propagates to R2/R3 via iBGP. Without full-mesh (R1-R2, R1-R3, R2-R3), R2 wouldn't know to route to R3.

Key differences:

AspecteBGPiBGP
--------------------
ASDifferentSame
TTL1255
Next-HopChangedUnchanged
Loop PreventionAS_PATHSplit-Horizon

BGP Session States and Troubleshooting

A BGP session goes through 6 states: Idle → Connect → Active → OpenSent → OpenConfirm → Established.

  • Idle: Waiting, no TCP.
  • Connect/Active: TCP 179 attempt.
  • OpenSent/Recv: Exchange OPEN (ASN, HoldTime=90s, Capabilities).
  • Established: Session up, exchanging UPDATE/WITHDRAW.
Analogy: Like a phone call: dialing (Connect), ringing (Active), greetings (Open), conversation (Established).

Troubleshooting example (show ip bgp summary):

  • Idle: ACL or interface issue.
  • Connect: No TCP (firewall?).
  • OpenConfirm → Established fail: ASN mismatch.

Case study: 2021 Facebook outage: BGP sessions down → 1-hour global blackout. Always check Keepalives (1/3 HoldTime) and Notifications for errors.

BGP Attributes: The Path Decision Makers

Attributes: Optional/transitive metadata attached to routes. 10+ types, but focus on essentials.

Well-Known Mandatory:

  • AS_PATH: List of ASes traversed (anti-loop, length as metric).
  • NEXT_HOP: IP of next hop (eBGP: peer IP; iBGP: unchanged).
  • ORIGIN: IGP (i), EGP (e), Incomplete (?).

Well-Known Discretionary: LOCAL_PREF (internal, higher wins).

Optional: MED (Multi-Exit Discriminator, inter-AS), COMMUNITY (tags for policies).

Analogy: AS_PATH is the path's resume (experience), LOCAL_PREF is internal salary.

Example: Route A: AS_PATH=100 200 (long), LOCAL_PREF=200. Route B: AS_PATH=300 (short), LOCAL_PREF=100. BGP picks A if LOCAL_PREF is prioritized.

BGP Path Selection Algorithm: Step-by-Step Priorities

BGP selects 1 best route per prefix via 13 steps (RFC 4271 + extensions):

  1. Highest WEIGHT (Cisco proprietary).
  2. Highest LOCAL_PREF.
  3. Shortest AS_PATH.
  4. ORIGIN: IGP > EGP > Incomplete.
  5. Lowest MED.
  6. eBGP > iBGP.
  7. Lowest IGP metric to Next-Hop.
  8. Oldest route (stability).
  9. Lowest Router ID.

Analogy: Like hiring: Experience (LOCAL_PREF), short resume (AS_PATH), low salary demand (MED).

Example: Two routes to 8.8.8.8/32:

  • Route1: LOCAL_PREF=200, AS_PATH=65001.
  • Route2: LOCAL_PREF=100, AS_PATH=65002 65003.
Choice: Route1 (LOCAL_PREF wins).

Essential Best Practices

  • Limit announcements: Use prefix-lists to advertise only your own /24+; avoid full tables (900k routes = memory intensive).
  • Use Route Reflectors for iBGP: Avoid full-mesh O(n²), unique cluster-id.
  • Apply communities: E.g., NO_EXPORT to block eBGP export.
  • Monitor: BGPmon, public Looking Glass; alert on flaps (>3/min).
  • Secure: TTL-Security (GTSM), MD5 auth, RPKI for ROA validation (anti-hijack).

Common Mistakes to Avoid

  • Forget Next-Hop self in iBGP: Route learned but unroutable (missing IGP).
  • AS_PATH loops: Don't import your own AS.
  • Default blackholing: No blackhole-community → DDoS amplification.
  • Full BGP table without filters: Router crash (memory exhaustion); use IRR/RPKI.
  • Ignore MED: Add always-compare-med for multi-homing consistency.

Next Steps for Deeper Learning

  • RFC 4271/7450/8205: BGP4/IPv6 standards.
  • Book: "Internet Routing Architectures" by Halabi (Cisco Press).
  • Tools: Hurricane Electric BGP Toolkit (bgp.he.net), BGPStream.
  • Pro training: Discover our advanced networking courses at Learni.
  • Practice: Free labs on GNS3 with Cisco/Juniper images.