Introduction to BGP Protocol


Introduction to BGP – The Backbone of Internet Routing

In this tutorial, we’ll go over the basics of BGP (Border Gateway Protocol) and what makes it different from other routing protocols. If you’re just getting started with routing or trying to understand how large networks communicate over the internet, this will help build a solid foundation.


1. What is a Routing Protocol?

A routing protocol is used by routers to learn about the networks around them and to decide the best path to reach a destination. Its main functions include:

  • Discovering routes to different networks
  • Selecting the best route based on metrics or policies
  • Updating routing tables dynamically when the network changes
  • Exchanging route information with neighboring routers

There are different types of routing protocols, and each one is used for specific scenarios. BGP is one of them—but it works differently from most others.


2. AS, IGP, and EGP – The Context of BGP

Before we understand BGP, we need to understand what an Autonomous System (AS) is.

  • An AS is a collection of IP networks and routers under a single organization or administrative domain.
  • Every AS has a unique number called the ASN (Autonomous System Number).

Now, routing protocols are broadly classified into two types:

  • IGP (Interior Gateway Protocol): Used within a single AS (e.g., OSPF, EIGRP, RIP)
  • EGP (Exterior Gateway Protocol): Used between different ASes

Border Gateway Protocol (BGP)  is the only EGP in use today. that routes data between different autonomous systems on the internet. RFC 4271 specifies BGP, highlighting its crucial role in maintaining the global internet’s vast, interconnected landscape.


3. What Makes BGP Different?

BGP is designed for very large and complex networks, like the internet. It’s different from traditional IGPs in two important ways:

a) Policy-Based Routing

Unlike protocols like OSPF that choose the shortest path based only on cost or metrics, BGP allows administrators to define routing policies.

You can choose routes based on business rules, security, performance, or agreements between organizations.

Imagine BGP as the internet’s diplomatic mediator, managing how different countries (or autonomous systems) interact to route data. It doesn’t just find the shortest path; it chooses the best route based on a set of agreed-upon rules.

b) Scalability

BGP can handle hundreds of thousands of routes, making it ideal for service providers and internet backbones. Protocols like OSPF and EIGRP are not designed to scale to that level.


4. BGP Peering – How Routers Communicate

Routers that run BGP don’t automatically discover neighbors like in OSPF. Instead, they form manual connections called BGP peerings or BGP sessions.

There are two types of BGP peerings:

  • iBGP (Internal BGP): Between routers within the same AS
  • eBGP (External BGP): Between routers in different ASes

The purpose of peering is to exchange routing information. Each peer advertises what networks it knows, and BGP decides how to reach them.

Unlike some other protocols, BGP does not require peers to be directly connected physically. Since it uses unicast IP addresses to establish TCP sessions, BGP peerings can be formed even over multiple hops. This is quite common in iBGP, where peers may be several routers apart.

However, in eBGP, direct connection is typically preferred unless additional configurations (like TTL settings or loopbacks) are used.


5. Path Vector Protocol and Attributes

BGP is a path vector protocol, meaning it doesn’t just say “I know a path,” but it also tells you how it got there.

Each BGP route comes with a set of path attributes that help routers decide the best path. These attributes include:

  • AS Path – the list of ASes the route passed through
  • Next Hop – the IP address to reach the destination
  • Local Preference, MED, Origin, etc. – used for policy decisions

This is what allows BGP to support complex routing decisions across the internet.


6. Why BGP Uses TCP

BGP uses TCP (port 179) to establish and maintain connections between peers.

Using TCP provides several advantages:

  • Reliable delivery of route updates
  • Connection management with built-in handshake and retransmission
  • No need for BGP to implement its own error checking or reliability logic

Because of this, BGP can focus purely on routing logic, and let TCP handle reliability.

Illustration of a BGP packet with encapsulated headers: BGP header showing message types (Open, Update, Keepalive, Notification), TCP header with destination port 179, IP header showing destination as neighbor’s unicast IP, and Ethernet header at the bottom.
BGP packet structure showing layered encapsulation: BGP over TCP, IP, and Ethernet

Summary Table

ConceptDescription
Routing ProtocolAllows routers to exchange and update route information
AS (Autonomous System)A group of networks under one organization with a unique ASN
IGPProtocols used within an AS (e.g., OSPF, EIGRP)
EGPProtocol used between ASes (BGP)
BGPA scalable, policy-based EGP used on the internet
iBGPPeering between routers within the same AS
eBGPPeering between routers in different ASes
Path VectorBGP uses path attributes to make routing decisions
TCPBGP uses TCP for reliable communication on port 179


We’d love to hear your feedback and suggestions about this article. Feel free to reach out to us using the WhatsApp number below.

Sajith Achipra has been a trainer and testing consultant at Zframez Technologies since 2009. With 15+ years of experience, he specializes in networking, Python, development, and testing. He conducts online courses to help students and professionals enhance their skills. You can reach him on WhatsApp at +91 8884 884 844 for your training and testing requirements.