What is BGP (Border Gateway Protocol)?

BGP (Border Gateway Protocol) is the routing protocol that connects the autonomous systems making up the internet. Learn how BGP works, what BGP route leaks and hijacks are, and why BGP is called the glue that holds the internet together.

BGP (Border Gateway Protocol) is the routing protocol that connects the thousands of independent networks that make up the internet, enabling them to exchange reachability information and route traffic globally.


TL;DR BGP (Border Gateway Protocol) is the internet’s primary inter-domain routing protocol. It connects autonomous systems (AS) — independent networks operated by ISPs, cloud providers, enterprises, and content delivery networks — and allows them to advertise which IP address ranges they can reach. BGP routers exchange this information and select the best path based on routing policies, not just shortest distance. BGP is why traffic from São Paulo can reach a server in Tokyo — it routes across dozens of autonomous systems to get there. BGP is defined in RFC 4271 and runs over TCP port 179.


What is BGP?

BGP (Border Gateway Protocol) is the exterior gateway protocol (EGP) used to exchange routing information between autonomous systems (AS) on the internet. It is the protocol that makes global routing possible.

BGP does not optimize for shortest path or lowest latency — it selects paths based on policies and attributes defined by network operators. This gives organizations control over how traffic enters and exits their networks.

BGP is the only protocol that operates at internet scale. As of 2026, the global BGP routing table contains over 900,000 prefixes (IPv4 + IPv6 combined).


What is an autonomous system (AS)?

An autonomous system (AS) is a collection of IP networks and routers under the control of a single organization, operating under a common routing policy.

Every autonomous system has:

  • A unique AS Number (ASN) assigned by a Regional Internet Registry (RIR).
  • One or more IP address blocks (prefixes) that it “owns” and advertises to the internet.

Examples:

  • Google: AS15169
  • Cloudflare: AS13335
  • Amazon AWS: AS16509
  • Azion: AS52580

ISPs, cloud providers, content delivery networks, and large enterprises all have their own ASNs. When your ISP connects to Google’s network, BGP routers on both sides exchange routing information using their ASNs.


How BGP works

BGP routers establish peering sessions over TCP port 179. Once established, they exchange:

  1. Their entire routing table (initial update)
  2. Incremental updates as routes change

Each BGP route carries path attributes that describe the route and influence selection:

AttributeDescription
AS_PATHThe sequence of AS numbers the route has traversed. Used for loop prevention and path selection.
NEXT_HOPThe IP address of the next router to reach the destination.
LOCAL_PREFLocal preference — higher is preferred. Used within an AS to influence outbound path selection.
MED (Multi-Exit Discriminator)A hint to neighboring ASes about the preferred entry point into your network.
COMMUNITYTag values attached to routes to apply routing policies across networks.

BGP path selection process

When multiple paths to the same destination exist, BGP selects one using a decision process (simplified):

  1. Highest LOCAL_PREF (prefer routes with higher local preference)
  2. Shortest AS_PATH (fewer hops)
  3. Lowest MED (prefer routes with lower cost signal from neighbor)
  4. Prefer eBGP over iBGP routes
  5. Lowest IGP metric to next hop
  6. Lowest router ID (tiebreaker)

iBGP vs eBGP

 iBGP (Internal BGP)eBGP (External BGP)
Used betweenRouters within the same ASRouters in different ASes
TTLUnlimited (within same AS)1 hop by default (directly connected)
Route propagationiBGP routes are not re-advertised to other iBGP peers (full mesh or route reflector required)eBGP routes are advertised to all peers
PurposeDistribute external routes internallyConnect autonomous systems

BGP peering: transit vs peering

Transit

A smaller network pays a larger network (upstream provider) to carry its traffic to the rest of the internet. The upstream provider advertises the smaller network’s prefixes to all of its peers and customers.

Peering

Two networks of similar size agree to exchange traffic between their customers directly, without payment. Peering reduces latency and transit costs. Large internet exchanges (IXPs) like DE-CIX, Equinix, and PTT Metro facilitate peering at physical locations.


BGP security issues

BGP was designed in 1989 with no built-in authentication or verification. This creates serious security risks.

BGP route leaks

A BGP route leak occurs when a network incorrectly advertises routes it learned from one peer to another peer, causing traffic to flow through unintended paths. In 2019, a small ISP in Pennsylvania accidentally leaked routes from Verizon to Cloudflare, redirecting large portions of internet traffic through their network and causing widespread outages.

BGP hijacking

BGP hijacking occurs when an attacker (or misconfigured router) announces IP prefixes they don’t own, attracting traffic destined for other networks. In 2008, Pakistan Telecom accidentally hijacked YouTube’s IP prefix globally, making the site unreachable worldwide for approximately 2 hours.

RPKI: resource public key infrastructure

RPKI (Resource Public Key Infrastructure) is a security framework that cryptographically validates the association between an IP prefix and the AS authorized to originate it.

With RPKI:

  • Each AS cryptographically signs a Route Origin Authorization (ROA) stating which ASes are authorized to announce its prefixes.
  • BGP routers can reject RPKI-invalid route announcements.

RPKI adoption has grown significantly since 2020. As of 2026, over 50% of the global routing table is covered by ROAs.


How BGP relates to internet infrastructure

BGP directly affects:

  • Latency — BGP path selection determines how many hops (and how many kilometers) traffic travels.
  • Availability — BGP enables multi-homing: connecting to multiple upstream providers so traffic reroutes around failures.
  • Content delivery — CDNs and distributed platforms use BGP anycast to route users to the nearest point of presence.
  • DDoS resilience — BGP blackholing routes attack traffic to a null route (discarding it) before it reaches the target.

Frequently asked questions

What is BGP in simple terms? BGP is the protocol that lets different internet networks talk to each other about which IP addresses they can reach. Think of the internet as thousands of separate neighborhoods. BGP is the postal system that lets each neighborhood announce its addresses and agree on how to forward mail between them.

What is an autonomous system (AS)? An autonomous system is a network or group of networks under the control of a single organization with its own routing policy. Every ISP, cloud provider, and large enterprise that connects to the internet has its own AS number (ASN), which uniquely identifies them in BGP routing.

Why is BGP called the glue that holds the internet together? Without BGP, the thousands of independent networks that make up the internet could not communicate with each other. BGP is the only protocol that operates at global internet scale, allowing networks in different countries and under different ownership to route traffic to each other.

What is a BGP route leak? A BGP route leak happens when a network incorrectly advertises routes it shouldn’t be advertising — for example, advertising to Peer A the routes it learned from Peer B. This can redirect large volumes of internet traffic through unintended networks, causing outages or enabling interception.

What is a BGP hijack? A BGP hijack is when an attacker announces IP prefixes they don’t own, claiming to be able to reach addresses that belong to another organization. Traffic destined for the victim’s network is redirected to the attacker. Hijacks can be used for traffic interception, spam sending, or simply taking a network offline.

What is RPKI? RPKI (Resource Public Key Infrastructure) is a security system that allows IP prefix owners to cryptographically sign records (Route Origin Authorizations) stating which AS numbers are authorized to announce their prefixes. BGP routers that enforce RPKI will reject announcements that don’t match these signed records, preventing many types of route leaks and hijacks.

What port does BGP use? BGP runs over TCP port 179. BGP sessions between routers are established over a persistent TCP connection, and routing updates are sent as incremental messages after the initial full table exchange.

What is the difference between BGP and OSPF? OSPF (Open Shortest Path First) is an interior gateway protocol (IGP) — it routes traffic within a single autonomous system and optimizes for shortest path. BGP is an exterior gateway protocol (EGP) — it routes traffic between autonomous systems and optimizes for policy compliance, not shortest path. Large networks use both: OSPF internally, BGP to connect to the rest of the internet.

stay up to date

Subscribe to our Newsletter

Get the latest product updates, event highlights, and tech industry insights delivered to your inbox.