BGP Explained: How the Internet Routes Its Traffic

BGP explained in plain terms means the system that lets separate networks agree on the best path for internet traffic to follow. The central question is how a message sent in one country finds its way to a server in another country when no single company owns the internet, and the short answer is that networks constantly share route information with each other using a protocol called the Border Gateway Protocol.

Every time you load a website or stream a video, your request crosses several different networks before it reaches its destination. Your home connection hands the traffic to your internet provider, which hands it to a larger carrier, and so on until it arrives.

None of that would work without a shared way of deciding which handovers to make. BGP is that shared system, and it has guided internet traffic for more than thirty years.

Key takeaways

  • BGP is the protocol that lets separate networks, called autonomous systems, share route information with each other.
  • Each network announces the address ranges it can reach, and its neighbours pass those announcements onward.
  • Routers choose paths using policies and path length, not simply the shortest geographical distance.
  • BGP runs over TCP, and its sessions between networks must stay up for routes to remain valid.
  • Mistakes and attacks on BGP can send traffic to the wrong place, which is why route validation matters.

What BGP is

BGP stands for Border Gateway Protocol, and it is the standard way that large networks exchange routing information across the internet. It is a path-vector protocol, which means that each route announcement carries a list of the networks it has already passed through, letting routers spot loops and judge distance.

The networks that speak BGP are called autonomous systems. An autonomous system is a network, or a group of networks, under one administrative control, such as an internet provider, a large company, or a cloud provider. Each one is identified by a unique autonomous system number, known as an ASN, which is assigned by regional internet registries.

BGP is an exterior gateway protocol, which means it works between networks rather than inside them. Inside a single network, engineers usually use interior protocols such as OSPF or IS-IS to find the best path between their own routers. BGP takes over at the border, where one network meets another, and it is the protocol that holds the global internet together.

How BGP works

BGP works through conversations between routers at the edges of neighbouring networks. Two routers first open a session, running on top of TCP port 179 for reliable delivery, then each sends the other a full list of the routes it knows, followed by updates only when something changes.

The basic unit of BGP is a prefix, which is a block of internet addresses, together with a set of attributes that describe the route. The most important attribute is the AS path, the list of autonomous system numbers the announcement has passed through. A shorter AS path is usually preferred, although it is not the only factor in the decision.

When a router receives a route announcement, it checks the AS path for loops and applies the policies its operators have set, which might prefer a cheaper link or favour a trusted partner. The router then chooses its best path, stores it in its routing table, and passes the announcement on, adding its own ASN to the path.

There are two kinds of BGP session. External BGP, known as eBGP, runs between routers in different autonomous systems, while internal BGP, known as iBGP, runs between routers inside the same autonomous system. The distinction matters because the two kinds follow different rules about which routes they pass on, and large networks use iBGP to spread what they learn from the outside world to all of their own routers.

Server racks in a dark room with a screen showing glowing green network paths
Server racks in a dark room with a screen showing glowing green network paths, a reminder that the internet is a physical network of machines agreeing on routes.

Route announcements are not permanent. If a link fails, a network goes down, or an operator withdraws a prefix, BGP sends a withdrawal message and the route disappears from the tables of its neighbours. That process, known as convergence, can take seconds or minutes, and during that time some traffic may take a longer path or fail to arrive at all.

Why BGP matters to everyone online

BGP matters because without it there would be no single internet, only a collection of disconnected networks. Your internet provider can only deliver traffic to destinations it knows how to reach, and it learns those destinations through BGP announcements from its neighbours. Every website, cloud service, and video stream you use depends on those announcements being correct.

The protocol also shapes how fast your connection feels. BGP path selection affects which route your traffic takes, how many networks it crosses, and how much delay it picks up along the way. Two providers in the same city can give noticeably different performance to the same website simply because their BGP policies send traffic along different paths.

BGP also sits underneath the everyday services that most people take for granted. Our guide to TCP/IP explains how data is broken into packets and reassembled at the other end, while our guide to DNS explains how a name such as a website address is turned into an internet address. BGP answers the next question: once the address is known, which networks should carry the packets there.

Businesses feel the effects of BGP even more directly. A company that announces its address ranges through BGP can connect to more than one provider at once, which gives it a backup if one link fails.

Comparing BGP with other routing methods

BGP is not the only way to route traffic, and the alternatives help to show what it is for. Small networks often use static routes, which are fixed entries typed in by hand, while larger networks use interior protocols that automatically find the best path between their own routers. BGP is the layer above those, where trust, policy, and business relationships matter as much as speed.

The table below sets out the main contrasts.

Aspect BGP OSPF Static routing
Where it runs Between autonomous systems Inside one network Inside one small network
What it optimises Policy, trust, and reachability Shortest path inside the network Simplicity and predictability
Scale Global, close to a million prefixes Thousands of routes A handful of routes
Updates Incremental announcements and withdrawals Link-state updates within the area Manual changes by an engineer
Path information Full AS path in each announcement Cost of each link None, just a next hop
Typical users Internet providers and large networks Enterprises and providers internally Home routers and small offices

The practical upshot is that the three methods work at different layers rather than competing, and BGP is the one that makes them into a single global system.

Strengths and limits

The greatest strength of BGP is its flexibility. Because operators can set their own policies, a network can prefer cheap links for bulk traffic, fast links for time-sensitive traffic, and trusted partners for sensitive destinations.

Scalability is another real advantage. BGP was designed in the early days of the internet and has grown with it, carrying a routing table that has expanded from thousands of prefixes to close to a million without a fundamental redesign. Its use of incremental updates keeps that growth manageable, since routers exchange only changes rather than whole tables.

The limits are just as real, though, and they come from the same trust that makes BGP work. In its original design, BGP largely trusted the announcements it received, so a network could accidentally or deliberately announce routes for address ranges it did not own. That is known as a BGP hijack when it is deliberate, and it can divert traffic, break services, or expose data to the wrong network.

Route leaks are a related problem. A leak happens when a network passes on routes it was only meant to use itself, and other networks start sending it traffic it cannot handle.

The result can be congestion, outages, and traffic taking long detours through networks that were never meant to carry it. Both hijacks and leaks have caused well-known internet outages, and they are a reminder that BGP was built for a smaller and more trusting internet than the one we have now.

BGP checklist

  • Learn what an autonomous system is before studying BGP, since every BGP concept builds on that idea.
  • Remember that BGP chooses paths by policy and AS path length, not by geography alone.
  • Check that BGP runs over TCP port 179, which is why its sessions are reliable but must stay up.
  • Distinguish eBGP between networks from iBGP inside a single network, as the two follow different rules.
  • Watch for route withdrawals as well as announcements, since a missing route can break reachability.
  • Expect convergence to take time after a failure, and plan for brief delays while tables settle.
  • Look for RPKI validation when judging whether a network takes BGP security seriously.
  • Do not confuse BGP with DNS, since DNS finds the address and BGP finds the path to it.
  • Test multihoming and backup links before an outage, rather than discovering a bad configuration during one.

Frequently asked questions

What is BGP in simple terms?

BGP is the protocol that lets separate internet networks share information about which address ranges they can reach. Each network announces its routes to its neighbours, and those announcements spread across the internet until every network knows how to reach every other network.

What does BGP stand for?

BGP stands for Border Gateway Protocol. The name reflects its job: it is the protocol that runs at the border between networks, deciding how traffic crosses from one autonomous system to another.

Why is BGP important?

BGP is important because it is what makes the internet a single connected system rather than a set of isolated networks. Without it, your provider would only be able to reach destinations it already knew about, and most of the websites and services you use would be unreachable.

How does BGP choose a route?

BGP chooses a route by looking at the attributes of each announcement, including the AS path, local preferences set by the operator, and the origin of the route. A shorter AS path is usually preferred, but an operator can override that with policy, for example by favouring a cheaper or more trusted link.

What is a BGP hijack?

A BGP hijack happens when a network announces routes for address ranges it does not own, so traffic meant for the real owner is sent to the wrong place. It can be an accident, such as a typing error in a configuration, or a deliberate attack, and it can cause outages or expose traffic to an attacker.

Can BGP be made more secure?

Yes, and the main tool is RPKI, which lets networks cryptographically check that an announcement comes from the rightful owner of an address range. Many large providers now use RPKI validation and reject invalid announcements, although adoption is not yet universal across the whole internet.

The bottom line

BGP explained in one line is this: a protocol that lets thousands of independent networks agree on how to reach each other, by sharing route announcements and choosing paths according to policy.

It is not the fastest or the most glamorous part of the internet, but it is one of the most important, and almost everything you do online depends on its announcements being correct.

This article is general information about how BGP works, not advice about configuring routing equipment for a particular network.

Latest articles

Scroll to Top