BGP Routing Explained
Understand how Border Gateway Protocol powers internet routing — from path selection to RPKI security and what it means for IPv4 address transfers. A guide by IPv4Center.
What Is BGP?
Border Gateway Protocol (BGP) is the exterior gateway routing protocol that governs how data packets are routed between autonomous systems (AS) on the internet. Defined in RFC 4271, BGP-4 is the only protocol capable of managing the full internet routing table, which contains over 1 million IPv4 prefixes as of 2026.
Every network connected to the internet — whether an ISP, cloud provider, enterprise, or content delivery network — uses BGP to announce the IP address prefixes it owns and to learn paths to every other prefix on the internet. Without BGP, there would be no mechanism for the roughly 75,000 autonomous systems worldwide to exchange reachability information.
BGP operates as a path-vector protocol, meaning it tracks the full AS path that a route has traversed. This is fundamentally different from interior gateway protocols like OSPF or IS-IS, which operate within a single organization. BGP uses TCP port 179 to establish sessions between peers, ensuring reliable delivery of routing updates.
How BGP Path Selection Works
When a BGP router receives multiple paths to the same destination prefix, it must select the best one. BGP uses a well-defined decision process that evaluates routes through a series of tie-breaking criteria. The router walks through these steps in order and stops as soon as a single best path is identified:
1. Highest Weight — A Cisco-proprietary attribute (local to the router). Higher weight is preferred. 2. Highest Local Preference — Shared within an AS via iBGP. Default value is 100; higher values are preferred. 3. Locally Originated Routes — Routes originated by the local router (via network statement or redistribution) are preferred. 4. Shortest AS Path — Fewer AS hops generally means a more direct route. This is the most commonly used traffic engineering lever. 5. Lowest Origin Type — IGP (i) is preferred over EGP (e), which is preferred over Incomplete (?). 6. Lowest MED — Multi-Exit Discriminator is a suggestion to external neighbors about the preferred entry point into your AS. 7. eBGP over iBGP — Externally learned routes are preferred over internally learned ones. 8. Lowest IGP Metric to Next Hop — The path with the closest next-hop router (by IGP cost) wins. 9. Oldest Route — For stability, the route that has been known the longest is preferred.
Network engineers use these attributes for traffic engineering — controlling which paths inbound and outbound traffic takes. Prepending additional AS numbers to the AS path is a common technique to make a path less attractive, while local preference is used to set outbound routing policy within an AS.
BGP and IPv4 Address Transfers
When you purchase IPv4 addresses, BGP announcement is a critical step in making those addresses usable on the internet. The transferred prefix must be announced from the buyer's Autonomous System Number (ASN), and upstream providers must accept and propagate that announcement for global reachability.
Before a transferred IPv4 block can be announced, several steps must be completed. The Regional Internet Registry (RIR) must update the WHOIS records to reflect the new holder. An RPKI Route Origin Authorization (ROA) must be created, binding the prefix to the buyer's ASN. The buyer's upstream transit providers must configure their routers to accept and propagate the new prefix.
The minimum prefix size accepted by most BGP peers on the global internet is /24 (256 addresses). Prefixes longer than /24 (such as /25 or /28) are typically filtered by upstream providers, meaning they will not be visible to the rest of the internet. This is why /24 is the standard minimum tradeable unit in the IPv4 transfer market.
Update RIR Records
WHOIS and RDAP records must reflect the new holder before announcement. RIR approval is required for inter-RIR transfers.
Create RPKI ROA
A Route Origin Authorization cryptographically binds the prefix to the authorized ASN, preventing hijacking.
Configure Upstream BGP
Transit providers must add the new prefix to their filters and accept the BGP announcement from the buyer's ASN.
Verify Global Visibility
Use looking glass tools and route collectors to confirm the prefix is visible from multiple vantage points worldwide.
BGP Security: RPKI and Route Origin Validation
Resource Public Key Infrastructure (RPKI) is the primary security framework for BGP, as defined in RFC 6811. RPKI allows IP address holders to cryptographically sign Route Origin Authorizations (ROAs) that declare which ASN is authorized to originate a specific prefix. This directly addresses the problem of route hijacking, where an unauthorized AS announces someone else's IP space.
Route Origin Validation (ROV) uses RPKI data to classify every BGP route into one of three states: Valid (a matching ROA exists and the originating AS is authorized), Invalid (a ROA exists but the originating AS or prefix length does not match), or Not Found (no ROA exists for the prefix). As of 2026, approximately 50% of IPv4 prefixes have RPKI coverage, and major networks including Cloudflare, Google, and AT&T drop Invalid routes.
For IPv4 address buyers, creating RPKI ROAs is essential. Without a valid ROA, networks performing ROV may filter the announcement, resulting in partial or no reachability. BGP security also extends to prefix filtering (IRR-based), BGPsec for path validation (RFC 8205), and operational best practices outlined in RFC 7454 (BGP Operations and Security).
RPKI ROA
Cryptographic attestation binding a prefix to an authorized ASN. Created through the RIR's hosted RPKI portal.
Route Origin Validation
Routers check incoming BGP announcements against RPKI data. Invalid routes can be deprioritized or dropped.
IRR Filtering
Internet Routing Registry objects (route/route6) are used by peers to build prefix filter lists independently of RPKI.
BGPsec (RFC 8205)
Provides cryptographic validation of the entire AS path, not just the origin. Adoption remains limited due to complexity.
Types of BGP Sessions
BGP sessions are categorized based on the relationship between the two routers involved. External BGP (eBGP) sessions run between routers in different autonomous systems. These sessions are the backbone of internet routing, carrying the full or partial routing table between networks. eBGP sessions use a default TTL of 1, meaning peers must typically be directly connected (though multihop eBGP is configurable).
Internal BGP (iBGP) sessions connect routers within the same AS. iBGP is used to distribute externally learned routes throughout the organization's network. Unlike eBGP, iBGP does not modify the AS path, and routes learned via iBGP are not re-advertised to other iBGP peers — this is the iBGP split-horizon rule, which requires either a full mesh of iBGP sessions or the use of route reflectors.
In the broader internet ecosystem, BGP sessions also differ by commercial relationship. Transit sessions provide a network with access to the full internet routing table in exchange for payment. Peering sessions exchange traffic between two networks for free (settlement-free peering), typically at Internet Exchange Points (IXPs). IXP route servers simplify peering by allowing a single BGP session to exchange routes with multiple peers simultaneously.
eBGP (External)
Sessions between different ASNs. Carries inter-domain routing information. Default TTL of 1 (directly connected).
iBGP (Internal)
Sessions within the same ASN. Distributes external routes internally. Requires full mesh or route reflectors.
Transit
Paid upstream connectivity providing access to the full routing table. The transit provider propagates customer routes globally.
IXP Peering
Settlement-free exchange of traffic at internet exchange points. Route servers enable multilateral peering via a single session.
Frequently Asked Questions
Common questions about BGP routing answered
BGP (Border Gateway Protocol) is the routing protocol that enables data to find its path across the internet. It allows the roughly 75,000 autonomous systems worldwide to exchange reachability information. Without BGP, internet traffic would have no way to traverse between different networks, ISPs, and content providers.
As of 2026, the global BGP routing table contains over 1 million IPv4 prefixes and over 200,000 IPv6 prefixes. This number grows steadily as new networks connect and existing address blocks are deaggregated through transfers and assignments.
The minimum IPv4 prefix size accepted by most BGP peers is /24 (256 addresses). Longer prefixes such as /25 or /28 are typically filtered by upstream providers and will not propagate globally. This makes /24 the smallest independently routable block on the internet.
RPKI (Resource Public Key Infrastructure) is a cryptographic framework that allows IP address holders to authorize specific ASNs to originate their prefixes. It prevents route hijacking by enabling networks to validate the origin of BGP announcements. Approximately 50% of IPv4 prefixes have RPKI coverage as of 2026.
BGP misconfigurations or hijacks can cause widespread internet outages. Notable incidents include the 2021 Facebook outage (caused by a BGP withdrawal of all their prefixes) and numerous route leaks where a network accidentally announces paths it should not. RPKI and prefix filtering help mitigate these risks.
Yes, if you want to announce the purchased prefix independently. You need an ASN (from your RIR) and at least one upstream transit provider. Alternatively, your hosting provider or ISP can announce the prefix on your behalf under their ASN, but this limits your control and portability.
An AS path is the ordered list of autonomous system numbers that a BGP route has traversed. For example, an AS path of "64500 64501 64502" means the route originated from AS 64502, passed through AS 64501, and was received from AS 64500. Shorter AS paths are generally preferred in BGP path selection.