What is BGP? The Complete Guide to Border Gateway Protocol

6 min read
5 November 2021

Uncover the secrets of the Border Gateway Protocol, learn how it works and find out why BGP is crucial for the effective operation of the internet.

What is border gateway protocol

The Border Gateway Protocol (BGP) routes data packets on the internet. It is the routing protocol responsible for interpreting where to send data and finding the best route for it to take. 

The internet consists of many different interconnected networks called autonomous systems (AS). The Border Gateway Protocol helps these large networks communicate with each other by exchanging routing information. 

In short, BGP enables networks to communicate by exchanging routing information between them. It also ensures that data travels from its source to its destination in the most efficient way.

There usually is more than one route possible between source and destination. And BGP finds valid and fastest routes for any given session.  

How does BGP work?

To understand BGP routing, it helps to think of the BGP system as the postal service. The mail system ensures that physical letters and packages travel fast and efficiently using the information in postal addresses. Similarly, BGP routes data according to the information in IP addresses

Just like the mail system, BGP relies on address-like identifiers called autonomous system numbers (ASN). These are unique to each autonomous system and help identify the intended destination of each data packet. 

The Border Gateway Protocol ensures speedy data routing. Even if that data is traveling to a different city, state, country or even continent. 

Chart of how Border Gateway Protocol works between autonomous systems.
BGP ensures routing of data packets between autonomous systems

BGP also helps guarantee network stability by being responsive to new paths and route failures. If one previously available route is no longer available, BGP is able to quickly establish new paths to compensate for the lost ones. 

While BGP is able to make automated decisions about routing based on available paths, it adheres to the rules and network policies set by network operators. Administrators can edit these rules when necessary. 

We can refer to BGP as a path vector protocol. That is because it is able to plan out the entire path to reach the destination. This may include passing through multiple ASs. Even when more than one route is possible, a valid and best route is chosen before routing data. 

We can compare the path vector protocol to the less efficient distance vector routing protocol. This routing protocol only takes notice of the next step in the routing process. It is not concerned with the whole path from source to destination.  

Autonomous system

The entire internet is not a single network. Instead, it is an intricate web of interconnected networks – autonomous systems. You may also refer to an AS as a routing domain.

In the mail system analogy, autonomous systems are the sorting offices. They receive incoming data and send it to the correct IP address within their network. They also make sure that outgoing data goes to the correct external AS. All of this is possible because of the BGP process. 

Single entities, such as educational institutions, governmental organizations, or, most commonly, internet service providers, manage autonomous systems. They may be composed of many smaller networks that are all united under a single routing policy. 

Every device connected to the internet, whether it’s a server, computer, smartphone or another smart device, is connected to an autonomous system. This means that to get data from another device, they need external or internal BGP routers to route the data correctly. 

Different internet-connected devices use BGP.
Every internet-connected device uses BGP

There are four types of AS: multihomed, stub, transit and Internet Exchange Point. They are unique based on how they connect to other ASs and how they are operated. 

We can characterize an AS as a collection of internet-connected Internet Protocol routing prefixes, or IP prefixes. This effectively means that when a packet of data is sent to a destination IP address, routers are able to narrow down the location of the destination device based on the AS with which the IP prefix is associated. 

BGP knows which AS contains which IP addresses based on their routing policy. 

Routing policies

Each autonomous system is unique because of its routing policy. This is what unifies all the constituent networks under one single AS. 

An important part of every unique routing policy is the list of IP address ranges (i.e., IP address space) within the AS. The other integral part of the routing policy is a list of all other autonomous systems, which the AS connects to. 

A system administrator who wants to create an AS must present a unique routing policy. This is crucial for getting an autonomous system number. 

Autonomous system number

Each autonomous system connected to the internet has a unique number to identify it. The ASN acts as the street address for the AS.

The Internet Assigned Numbers Authority (IANA) manages and assigns ASNs on a global level. However, when network administrators want to create a new AS, they have to apply to their relevant Regional Internet Registries (RIR). 

For example, the American Registry for Internet Numbers (ARIN) operates in North America. Réseaux IP Européens Network Coordination Center (RIPE NCC) operates in Europe, the Middle East and Central Asia. There are five RIRs in total.

Regional internet registry regions.
Map of Regional Internet Registries’ service regions

ASNs make routing protocols more efficient by helping identify the shortest BGP route for data to take to reach its destination. 

The best route for traffic across the global internet may pass through more than one AS. However, since ASNs are linked to their routing policies, it’s possible to map new routes and pick from multiple routes leading to the same destination to find the most efficient one. 

The internet operates BGP autonomous systems so that data does not get lost or spend too long going to its final destination. Ultimately, BGP runs effectively only with the help of ASNs that point traffic in the right direction. 

To sum up, ASNs are essential for the smooth running of the internet. 

How does BGP communicate AS paths?

BGP uses ASNs to identify each service and works as a routing protocol for AS paths on the network.

This whole process relies on BGP routing tables, which are the backbone of the BGP system. Each router’s routing table stores information about the various available routes to particular network destinations, as well as metrics about the route. 

By assessing these route options and their metrics, BGP is able to choose the shortest path for any given data packet. To provide the best of the multiple possible paths to a destination, the BGP speaker advertises routes from its routing table that represent the most valid and efficient option. 

Internal and external BGP

The difference between internal and external BGP is pretty simple. It basically depends on whether the BGP session occurs between two devices within the same AS or between devices in different ASs. 

How external and internal BGP work on different autonomous systems.
External BGP vs. internal BGP

When two neighboring devices or networks within the same AS (internal networks) share data, internal routers manage BGP. Internal BGP, or iBGP for short, does not communicate with other ASs when the process is only required between two internal peers. 

On the other hand, if the BGP session occurs between two BGP neighbors in different ASs, this is called external BGP, or eBGP for short. This simply means that the BGP process involves the interfacing of two ASs with the aid of edge routers. 

Returning to the mail system analogy, this would represent the difference between local and long-distance mail. Local mail doesn’t travel to a regional sorting office, since it is only traveling a short distance to an address within the same locality. 

Ultimately, using iBGP where possible ensures that routing is more efficient, as one AS’s BGP router does not need to exchange routing information with another.  

Conclusion

So, what is BGP? To quickly summarize, Border Gateway Protocol (BGP) is the default routing protocol of the internet. Its primary function is to facilitate the exchange of routing information between different autonomous systems. 

It’s easiest to think of BGP as a mail system that uses autonomous system numbers as addresses to route packets of data (i.e., mail) to the destination using the shortest possible route. 

With the help of ASNs and routing tables, BGP routers are able to direct traffic via the most efficient path to its final destination. 

About the author

Beatričė Raščiūtė

Technical Content Writer

Beatričė is a Technical Content Writer at IPXO. Having experience in translations, she decided to test new waters in the tech industry as a writer. While creating content, she dives deep into different internet and networking topics with the goal to present valuable information in the most reader-friendly way.
Table of contents

Related reading

a featured image for an article What Is Network Address Translation? A Beginner’s Guide to NAT

What Is Network Address Translation? A Beginner’s Guide to NAT  

Discover why Network Address Translation is important, how it works and what different types of NAT are available.

Read more
A featured image for an article Understanding the Difference: WAN vs LAN

Understanding the Difference: WAN vs LAN

What is a local area network? What is a wide area network? How do they differ and how are they similar? You can find answers to these questions in…

Read more
How does network routing work between computer and server

A Comprehensive Guide to Network Routing

What is networking and how does it work? What is a routing table and the main routing protocols? We've got the answers.

Read more

Subscribe to the IPXO email and don’t miss any news!