What is BGP (Border Gateway Protocol)?

Share This Article

Updated on May 12, 2025

The Border Gateway Protocol (BGP) is essential to how the internet works. It manages global routing by allowing networks, called Autonomous Systems (ASes), to share routing information. As a path-vector protocol, BGP makes routing decisions based on path details and administrator policies. It ensures data packets reach their destinations across interconnected systems.

In this guide, we’ll explain the basics of BGP, how it works, its key features, and its real-world uses.

Definition and Core Concepts

Autonomous System (AS)

An Autonomous System (AS) is a collection of IP networks and routers under a single organization’s management, with a unified routing policy. Each AS is identified by an Autonomous System Number (ASN), a unique identifier that ensures networks can communicate efficiently. BGP is designed to facilitate communication between multiple ASes.

Exterior Gateway Protocol (EGP)

BGP is categorized as an exterior gateway protocol. Unlike interior gateway protocols (IGPs), which operate within a single AS, BGP is responsible for routing between ASes. It exchanges high-level routing information to ensure seamless traffic flow across diverse networks.

Path-Vector Routing

Path-vector routing is BGP’s decision-making framework. Unlike simpler distance-vector or link-state protocols, BGP considers a range of attributes to determine the best path for routing data. These include the list of ASes a route traverses (known as an AS path) and other configurable policies.

BGP Peers

BGP peers, also referred to as neighbors, are two routers that establish a TCP-based connection to exchange routing information. This peering relationship can occur within an AS (iBGP) or between different ASes (eBGP).

BGP Attributes

BGP attaches attributes to each route, which play a critical role in route selection. Key attributes include AS path, next hop, Multi-Exit Discriminator (MED), and Local Preference. These attributes allow network administrators to define routing policies.

BGP Messages

Communication in BGP relies on four message types:

  1. Open messages establish a connection between peers.
  2. Update messages share routing information and changes.
  3. Keepalive messages maintain the connection between peers.
  4. Notification messages signal errors or terminate connections.

BGP Route Selection

When multiple routes are available to the same destination, BGP applies a multi-step route selection process, evaluating various path attributes such as Local Preference, AS path length, Origin, and Multi-Exit Discriminator (MED) to determine the best path. The specific order and weight of these attributes can be influenced by vendor implementations and administrator configurations. Configurable policies ensure flexibility for administrators to prioritize routes according to organizational needs.

How It Works

Neighbor Establishment

BGP starts by initiating a connection between two routers, known as peers. This connection is established over TCP, typically on port 179. During this process, peers exchange Open messages to set parameters such as AS numbers and supported BGP versions.

Route Advertisement

Once a connection is established, BGP peers exchange route advertisements. These advertisements include network prefixes originated by the advertising AS, along with associated path attributes that describe the path to those prefixes. Subsequent updates propagate information about paths to reach other networks learned from neighboring ASes.

Path Attributes

Path attributes are pivotal in how BGP manages routes. The AS path indicates the list of ASes a route passes through, while the next hop attribute specifies the next router in the path. Additional attributes like MED and Local Preference allow further control over routing policies.

Route Selection Process

To select the best route, BGP follows a predetermined sequence of criteria:

  1. Prefer routes with the highest Local Preference.
  2. Choose the shortest AS path (fewer AS hops).
  3. Prefer routes originated by the lowest Origin value.
  4. Use the lowest MED value for otherwise equal paths.
  5. Prefer external (eBGP) routes over internal (iBGP) routes.

BGP Updates

When routing information changes, BGP sends updates to its peers. Update messages include only the changes (rather than a full table), ensuring efficient communication while maintaining accurate routing tables.

Keepalive Messages

To ensure that the BGP connection between peers remains active, Keepalive messages are exchanged periodically. These lightweight messages act as a heartbeat to verify that both routers are operational.

Key Features and Components

Inter-AS Routing

BGP is uniquely designed to handle routing between multiple Autonomous Systems, making it the backbone protocol for internet-level routing.

Policy-Based Routing

With its ability to implement customizable policies, BGP enables organizations to prioritize certain routes over others, optimize traffic flow, or meet specific business goals.

Path Attributes

The inclusion of path attributes like AS path and next hop provides transparency and flexibility. These attributes enable granular control over how routes are evaluated and selected.

Stability and Scalability

BGP is built for scalability. Its hierarchical system organizes the internet’s routing infrastructure efficiently, and its built-in mechanisms ensure stability even in the face of fluctuating network conditions.

Support for CIDR

Classless Inter-Domain Routing (CIDR) is supported by BGP to minimize the size of routing tables. CIDR allows IP address aggregation, simplifying routing while conserving address space.

Use Cases and Applications

Internet Backbone Routing

BGP is the protocol responsible for maintaining and routing the global backbone of the internet. Internet Service Providers (ISPs) and Tier 1 providers rely on BGP to exchange routing information and ensure seamless connectivity for users worldwide.

Connecting Large Organizations to the Internet

Enterprises that operate their own AS can leverage BGP to connect to ISPs while maintaining control over routing policies. This setup ensures efficient and reliable access to external networks.

Interconnecting Different Autonomous Systems

Organizations operating multiple ASes frequently use BGP to interconnect their systems. This approach enables efficient traffic flow and allows for fine-tuned routing policies across different parts of the network.

Implementing Complex Routing Policies

BGP’s flexibility makes it ideal for organizations with unique routing needs. For example, companies can configure BGP to prioritize certain traffic paths, balance load efficiently, or meet specific compliance requirements.

Key Terms Appendix

  • Autonomous System (AS): A group of IP networks under a single administrative domain with unified routing policies.
  • Exterior Gateway Protocol (EGP): Protocols designed for inter-AS routing, such as BGP.
  • Path-Vector Routing: A method of routing that bases decisions on paths, policies, and rule sets.
  • BGP Peer: Two routers that establish a BGP connection to exchange routing information.
  • BGP Attributes: Metrics like AS path, next hop, and MED that influence route selection.
  • BGP Messages: Four message types (Open, Update, Keepalive, Notification) that support BGP communication.
  • CIDR (Classless Inter-Domain Routing): A method for efficient IP address aggregation and routing table reduction.

Continue Learning with our Newsletter