The global Internet is not a single unified network, but a collection of over 75,000 independently managed networks called Autonomous Systems (AS). The glue that binds these distinct networks together and allows data packets to cross international borders and Internet Exchange Points (IXPs) is the Border Gateway Protocol (BGP-4 - RFC 4271).
Direct Answer: BGP is a Path-Vector routing protocol used to exchange routing and reachability information between Autonomous Systems on the Internet. Unlike interior gateway protocols (like OSPF or IS-IS) that calculate the shortest physical path based on link bandwidth, BGP selects paths based on business relationships, security policies, Local Preference, and Autonomous System hop count (AS-PATH). BGP does not guarantee routing through the geographically shortest route.
1. Autonomous System Numbers (ASN) & Peering Types
An Autonomous System (AS) is a group of IP prefixes under a single clearly defined administrative domain (e.g., Cloudflare AS13335, Google AS15169, Comcast AS7922). Each AS is assigned a unique ASN by Regional Internet Registries (RIRs like ARIN, RIPE, APNIC).
Client (AS 7922 Comcast) ββeBGP SessionβββΊ Transit Provider (AS 3356 Lumen) ββeBGP SessionβββΊ Hosting Provider (AS 13335 Cloudflare)
BGP Session Types:
- eBGP (External BGP): Runs between routers in different Autonomous Systems. Used to exchange network prefixes across border routers.
- iBGP (Internal BGP): Runs between routers within the same Autonomous System to distribute exterior routes learned via eBGP across internal core routers.
To inspect ASN registration data, IP ownership, and domain domain lookup details, use the IP Address Lookup and Domain WHOIS Checker.
2. The BGP Best Path Selection Algorithm
When a BGP router receives multiple advertised paths to the exact same IP prefix (e.g., 192.0.2.0/24), it evaluates attributes in strict sequential order until a single tie-breaker path is chosen:
- Highest Weight: Cisco-proprietary local attribute (local to the router).
- Highest Local Preference (
LOCAL_PREF): Standard attribute communicated across iBGP. Indicates administrative preference (e.g., prefer free settlement-free peering over paid transit). - Self-Originated Routes: Prefers routes originated locally via
networkoraggregatestatements. - Shortest AS-PATH Length: Prefers paths that cross the fewest Autonomous System hops (e.g.,
AS15169 AS13335beatsAS7922 AS3356 AS13335). - Lowest Origin Type: Prefers IGP origin over EGP, and EGP over Incomplete (
?). - Lowest Multi-Exit Discriminator (
MED): Used by neighboring ASes to suggest which ingress link to prefer. - eBGP over iBGP: Prefers external eBGP paths over internal iBGP paths.
- Lowest IGP Metric: Prefers path to next-hop router with the lowest interior gateway cost.
- Lowest Router ID: Final deterministic tie-breaker based on the neighbor's IP.
3. Key Differences: BGP vs OSPF
| Feature / Metric | Border Gateway Protocol (BGP-4) | Open Shortest Path First (OSPF) |
|---|---|---|
| Protocol Classification | Exterior Gateway Path-Vector Protocol | Interior Gateway Link-State Protocol |
| Scope | Inter-AS (Global Internet Routing) | Intra-AS (Enterprise Internal Networks) |
| Metric / Decision Basis | Policy, Local Preference, AS-PATH length | Link Cost (Calculated from Bandwidth) |
| Scale Limit | 900,000+ global IPv4 routes | Typically thousands of internal subnets |
| Transport Protocol | TCP Port 179 (Reliable connection) | Raw IP Protocol 89 |
| Convergence Time | Seconds to minutes (BGP flap damping) | Sub-second fast reroute (LFA) |
4. BGP Hijacking & Security (RPKI)
Because BGP originally trusted all route advertisements from peered neighbors, malicious or misconfigured networks could advertise IP prefixes they did not ownβa vulnerability known as BGP Hijacking.
To secure Internet routing, the global networking community implemented RPKI (Resource Public Key Infrastructure). RPKI allows network operators to publish cryptographic Route Origin Authorizations (ROAs) in a public key hierarchy, allowing BGP routers to validate whether an AS is cryptographically authorized to originate a given IP prefix.
For testing global host connectivity and DNS record mapping, utilize the DNS Lookup and test latency with the Ping Test.
5. Frequently Asked Questions (FAQs)
Does BGP always route traffic through the geographically shortest path?
No. BGP's best-path selection algorithm prioritizes attributes like Local Preference and AS-PATH length (the number of Autonomous System hops), which reflect business and peering relationships rather than physical distance or link latency. Traffic between two geographically close networks can take a long detour if that path is preferred for commercial reasons.
What is BGP route hijacking and how common is it?
BGP hijacking occurs when a network operator, accidentally or maliciously, advertises IP prefixes it does not own, causing other networks to route traffic for those addresses incorrectly β sometimes through the hijacker, enabling traffic interception. It has occurred numerous times at internet scale, including high-profile incidents affecting major cloud and financial services, which is why RPKI Route Origin Validation has become increasingly mandatory among major transit providers.
What's the practical difference between eBGP and iBGP?
eBGP sessions run between routers in different Autonomous Systems and exchange reachability information across organizational boundaries, typically over directly connected border routers. iBGP sessions run between routers inside the same AS to propagate those externally learned routes to every internal router, keeping routing decisions consistent across the network without each internal router needing its own eBGP session to the outside world.
References: IETF RFC 4271 (A Border Gateway Protocol 4 - BGP-4); IETF RFC 6480 (An Infrastructure to Support Secure Internet Routing - RPKI).