BGP and CIDR: How the Internet Exchanges Routing Information
BGP is the routing protocol that connects the internet's 80,000+ autonomous systems. CIDR is the addressing scheme that makes BGP routing tables manageable. Here's how they work together.
The internet is not one network — it is approximately 80,000 separate networks (Autonomous Systems, or ASes) that have agreed to exchange routing information. The protocol that carries this information is BGP (Border Gateway Protocol). Every time you access a website, dozens of BGP routing decisions determine the path your packets take. CIDR is the addressing language BGP speaks.
What BGP Does
BGP is an exterior routing protocol — it operates between ASes, not within them. Each AS announces the IP prefixes it can reach: "I am AS64512 and I can deliver packets destined for 203.0.113.0/24." Neighbouring ASes receive this announcement, evaluate it against their policies, and propagate it further if they choose to. Eventually, the announcement reaches routers worldwide, and they update their routing tables accordingly.
CIDR Prefixes as BGP Advertisements
BGP routes are CIDR prefixes. When an organisation receives an IP allocation from their Regional Internet Registry (RIPE, ARIN, APNIC, etc.), they receive a block like 198.51.100.0/22. They announce this prefix to their upstream ISPs via BGP. Their ISPs may aggregate it with adjacent blocks into a less-specific announcement, or pass it along as-is. The global BGP table is a collection of several hundred thousand such prefix announcements.
Route Aggregation in BGP
Without aggregation, every organisation's individual subnets would appear in the global routing table — hundreds of millions of entries. CIDR aggregation allows ISPs to summarise their customers' prefixes into a single announcement. An ISP holding blocks 192.0.2.0/24 through 192.0.7.0/24 might aggregate them into one announcement of 192.0.0.0/21. See our CIDR aggregation guide for the binary arithmetic. Aggregation is why the global routing table has ~950,000 entries rather than billions.
Longest Prefix Match
When a router has multiple routes that could match a destination, it chooses the most specific — the longest prefix. A packet destined for 10.0.0.50 would match both 10.0.0.0/8 and 10.0.0.0/24. The router selects 10.0.0.0/24 as the better match. This longest-prefix-match rule is fundamental to how all IP routing works, from your home router to internet core routers.
BGP and Cloud Providers
Cloud providers are some of the largest BGP participants. AWS announces thousands of CIDR prefixes globally — you can see a subset of them on our AWS IP ranges page. When your browser connects to an AWS-hosted service, BGP routing directs your traffic to the nearest AWS point of presence. When you use AWS Direct Connect, you run BGP directly with AWS to exchange routes between your on-premises network and your VPC.