What Is BGP? How Internet Routing Works
Key takeaways
- BGP exchanges routes to address blocks called prefixes.
- An autonomous system is a network, or collection of networks, operating under a defined routing policy.
- Route selection follows network policy; it does not always choose the fewest hops or lowest latency.
- BYOIP needs correct routing as well as permission to use an address block.
On this page
BGP stands for Border Gateway Protocol. It lets networks exchange information about how to reach IP address blocks, helping routers select routes across the internet. A network announces the prefixes it can reach, and neighboring networks decide which routes to accept and use.
BGP is part of the coordination behind internet connectivity. You do not normally interact with it when opening a website, but the networks carrying your traffic depend on routing information to know where to send it.
Why does the internet need BGP?
The internet connects independently operated networks. An access provider, a cloud platform, and a university may each manage their own infrastructure and relationships with other networks.
These operators need a way to exchange reachability information without one organization controlling everyone’s routing decisions. BGP provides that exchange. Cloudflare’s BGP introduction describes how interconnected networks use it to share routes and apply their own preferences.
A useful distinction is that BGP helps establish routing information. Routers then forward packets using their forwarding tables. They do not negotiate a new BGP route for every page view or individual packet.
What are autonomous systems and ASNs?
An autonomous system, or AS, groups networks under a clearly defined routing policy. An Autonomous System Number, or ASN, identifies that system in routing exchanges. The operational definition is set out in RFC 1930.
ASNs allow a route to describe the sequence of autonomous systems associated with its path. They identify routing domains, rather than individual servers or every physical router along the way.
You do not need your own ASN simply to browse the web or host a site with an ordinary provider. For the identifier itself, read What Is an ASN?
What does a BGP announcement contain?
A route announcement identifies a destination prefix and provides attributes used to evaluate the route. Two useful concepts are the AS path, which describes the autonomous-system path, and the next hop, which helps the receiving router determine where to forward traffic.
For example, a provider can announce reachability to an IPv4 /24 instead of publishing a separate route for every address in that block. Prefixes and route attributes are part of the BGP-4 specification, RFC 4271.
An announcement communicates reachability. It is not, by itself, proof that the announcing network is authorized to originate the prefix.
A simple BGP routing example
Imagine a destination prefix, 203.0.113.0/24, originated by AS64496. Another network receives these two candidate routes to that same prefix:
| Route learned from | AS path shown in the announcement |
|---|---|
| Provider B | 64497 64496 |
| Provider C | 64498 64499 64496 |
In these simple paths, the rightmost ASN is the origin. The first route lists fewer autonomous systems, but that does not guarantee it will be selected. The receiving network might have a policy that prefers Provider C, such as a higher local preference.
This is an invented teaching example. Its IPv4 prefix is reserved for documentation by RFC 5737, and the ASNs come from the documentation range in RFC 5398. It does not describe live internet routing.
An AS path also does not reveal the physical distance, available bandwidth, or number of routers inside each network. Counting the entries is not a speed test.
How does BGP choose a route?
Operators first decide which announcements are acceptable. Among eligible routes, preferences and path attributes help select the route to use. Local preference can take priority over AS-path length, as described in RFC 4271’s decision process.
This lets networks reflect commercial relationships and operational requirements in their routing. Two networks can receive information about the same destination and make different choices.
When a route is withdrawn or a BGP session fails, affected routers update their routing information. Another route may become available, but a usable alternative is not guaranteed. Updates also take time to spread; BGP does not promise instant recovery.
BGP, DNS, and IP do different jobs
These terms describe different parts of a connection:
| Component | Role in a website visit |
|---|---|
| DNS | Helps resolve the website’s hostname to an address |
| BGP | Helps networks learn and select routes to the destination prefix |
| IP | Provides packet addressing used when forwarding traffic |
A correct DNS response does not prove the destination is reachable. A valid route does not prove the web application is healthy. When a site fails, identifying the layer at fault makes troubleshooting more useful than changing unrelated settings.
How does BGP relate to BYOIP?
With Bring Your Own IP, a supported provider can use an address range you control for services on its infrastructure. For traffic to reach it there, the routing and provider configuration must match the intended deployment.
For example, AWS’s BYOIP onboarding workflow includes provisioning a range and advertising it. A lease, transfer, or registry record alone does not complete that workflow.
Treat a provider move as a coordinated change: establish the required permissions, prepare the destination service, arrange the announcement change, and verify traffic reaches the application. Our BYOIP introduction explains the broader process.
How is BGP made safer?
Operators use controls such as prefix filtering and limits on accepted routes. These practices help contain incorrect or unexpected announcements; see the operational recommendations in RFC 7454.
RPKI origin validation adds a check against cryptographically verifiable authorization data. It can help determine whether the origin ASN is authorized for a prefix. It does not validate the entire AS path or certify that traffic from an address is trustworthy. Read RPKI, ROAs, and origin validation for that distinction.
FAQ
Related resources
Ready to see where BYOIP is supported?
Continue the series
Why Are IPv4 Addresses Running Out?
IPv4 exhaustion limits the supply of additional addresses. Learn why existing connections keep working and what options networks have for growth.
5 min read · Updated 11 September 2026
Read articleWhat Is IPv4 Leasing, and How Does It Work?
IPv4 leasing provides access to address space for an agreed period. Understand the costs, routing setup, and practical checks before choosing a block.
6 min read · Updated 11 September 2026
Read article