Skip to main content
Cloud & AI Hub
Browse
Glossary AI Directory Playgrounds Models Prompts Explainers Strategy Matrix Benchmark Decoder
advanced 10 mins Read

How BGP Routing Protocols Connect the Internet

A deep-dive into Border Gateway Protocol — the routing protocol that glues thousands of autonomous systems into a single global internet.

Introduction

The internet is not a single network — it is a collection of roughly 100,000 independently operated networks called Autonomous Systems (ASes), each assigned a unique ASN (Autonomous System Number) by regional internet registries like ARIN, RIPE, and APNIC. Your ISP is an AS. Google is an AS. AWS is an AS. Each AS controls its own IP address blocks and routing policy. Border Gateway Protocol (BGP), defined in RFC 4271, is the exterior routing protocol that allows these autonomous systems to exchange reachability information and calculate the best paths for traffic to travel across the global internet.

BGP is a path-vector protocol — unlike interior routing protocols like OSPF (which use link-state metrics such as cost or bandwidth), BGP routers advertise complete AS paths alongside each prefix. When AS 64500 tells AS 64501 “I can reach 203.0.113.0/24 via path [64500, 13335]”, AS 64501 gains complete visibility into the routing path, enabling loop prevention and policy-based filtering.

Step-by-Step: How BGP Establishes and Propagates Routes

flowchart TD
    A["1. BGP Session Establishment (OPEN Message)"]
    B["2. Route Advertisement (UPDATE Message)"]
    C["3. Route Selection (Best Path Algorithm)"]
    D["4. Route Propagation Rules"]
    E["5. Route Filtering and Policy"]
    A --> B
    B --> C
    C --> D
    D --> E

Step 1: BGP Session Establishment (OPEN Message)

Two BGP routers form a peer session over a TCP connection on port 179. They exchange OPEN messages containing their ASN, BGP version (4), hold time, and BGP router ID (typically the highest IP on the router). After mutual acceptance, the session enters ESTABLISHED state and the peers begin exchanging routing tables.

BGP State Machine:
IDLE → CONNECT → ACTIVE → OPEN SENT → OPEN CONFIRM → ESTABLISHED

Step 2: Route Advertisement (UPDATE Message)

Once established, peers send UPDATE messages advertising new prefixes or withdrawing stale ones. Each update includes:

  • NLRI (Network Layer Reachability Information): The IP prefix being advertised (e.g., 1.1.1.0/24)
  • AS_PATH: The sequence of ASes the route traversed (e.g., [13335, 6939, 3356])
  • NEXT_HOP: The IP address of the next router along the path
  • LOCAL_PREF: An internal preference value (higher = preferred, used within a single AS)
  • MED (Multi-Exit Discriminator): A hint to neighboring ASes about preferred entry points

Step 3: Route Selection (Best Path Algorithm)

When a BGP router receives multiple paths to the same prefix, it runs the BGP best-path selection algorithm in order:

  1. Highest WEIGHT (Cisco-proprietary, local only)
  2. Highest LOCAL_PREF (internal preference, default 100)
  3. Routes originated by this router preferred
  4. Shortest AS_PATH length
  5. Lowest ORIGIN (IGP < EGP < Incomplete)
  6. Lowest MED
  7. eBGP over iBGP routes
  8. Lowest IGP metric to NEXT_HOP
  9. Lowest BGP Router ID (tiebreaker)

Step 4: Route Propagation Rules

BGP enforces strict propagation rules to prevent routing loops:

  • eBGP (external): Routes learned from one external peer are advertised to all other peers
  • iBGP (internal): Routes learned from an internal peer are NOT re-advertised to other internal peers (to prevent loops) — requiring either full iBGP mesh or route reflectors
# View BGP routing table
show ip bgp summary
show ip bgp 1.1.1.0/24

# On Linux with BIRD or FRR:
birdc show route 1.1.1.0/24 all

Step 5: Route Filtering and Policy

Network operators apply prefix lists, route maps, and communities to control what routes are accepted and advertised. BGP communities (32-bit tags like 13335:1000) are used to signal routing policy between peers — for example, telling an upstream provider to deprioritize a route or not export it further.

# Example FRRouting config — accept only routes in a prefix list
neighbor 198.51.100.1 route-map FILTER-IN in
!
ip prefix-list ALLOWED-IN permit 10.0.0.0/8 le 24

Key Takeaways

  • BGP is a path-vector protocol operating over TCP/179 — it is policy-driven, not metric-driven like OSPF or EIGRP.
  • The AS_PATH attribute is the primary loop-prevention mechanism and a key factor in route selection.
  • iBGP split-horizon rules require full mesh or route reflectors to propagate routes inside an AS.
  • BGP communities enable scalable policy signaling between thousands of peering relationships without manual per-peer configuration.
  • BGP hijacking (advertising someone else’s prefix) is a real attack vector; RPKI (Resource Public Key Infrastructure) cryptographically validates prefix ownership to mitigate this.

Historical figures, architectures, and capabilities are for informational purposes only. Not technical, professional, legal, or financial advice. Sources: Research papers, developer documentation.