BGP (Border Gateway Protocol)

What is BGP (Border Gateway Protocol)?

BGP (Border Gateway Protocol) is the protocol that enables the global routing system of the internet. It manages how packets get routed from network to network by exchanging routing and reachability information among edge routers.

BGP enables peering to send packets between autonomous systems (ASes), which are networks managed by a single enterprise or service provider. Together, these ASes make up the public internet.

BGP creates network stability by guaranteeing that routers can adapt to route failures. When one path goes down, BGP quickly finds a new path. BGP makes routing decisions based on paths, defined by rules or network policies set by network administrators.

How does BGP work?

Each router maintains a routing table that controls how packets are directed. The BGP process on the router generates routing table information, which is based on the following factors:

  • Incoming information from other routers.
  • Information in the BGP routing information base (RIB), which is a data table stored on a server on the BGP router.

The RIB contains information both from directly connected external peers and internal peers. The RIB contains policies for what routes should be used and what information should be published, and it continually updates the routing table as changes occur.

What is BGP used for?

BGP helps provide redundancy by enabling routers to quickly adapt and send packets through another connection if one internet path goes down. It is often used in large networks, such as internet service provider networks, wide area networks and infrastructure-as-a-service environments.

BGP is an exterior gateway protocol, which means it is designed to share routing information between different ASes. Alternatively, an interior gateway protocol sends information within a single AS. However, Internal BGP (iBGP) is available to send reachability information within an organization's network.

Each BGP router maintains a standard routing table used to direct packets in transit. BGP uses client-server topology to communicate routing information, with the client initiating a BGP session by sending a request to the server.

BGP routing basics

BGP sends updated router table information only when something changes, and it sends only the affected information. BGP has no automatic discovery mechanism, which means network admins must manually set up connections between peers, with peer addresses programmed in at both ends.

BGP makes best-path decisions based on attributes that include the following:

  • Highest weight.
  • Current reachability.
  • Hop counts.
  • Local preference.
  • Oldest path.

In situations where multiple paths are available -- as within a major hosting facility -- BGP policies communicate an organization's preferences for what path traffic should follow in and out. BGP community tags can control route advertisement behavior among peers.

BGP in networking is based on the TCP/IP model. It operates on the Open Systems Interconnection transport layer (Layer 4) to control the network layer (Layer 3).

As described in RFC 4271 and ratified in 2006, the current version of BGP-4 supports both IPv6 and Classless Inter-Domain Routing (CIDR), which enables the continued viability of IPv4. Using CIDR enables a network to have more network addresses than with the current IP address assignment scheme.

Diagram of BGP deployment on core routers and peering points
Users can deploy BGP only where needed, such as on peering points and select core routers.

Common BGP issues

Common issues with BGP include information exchange failures. Information exchanges don't always succeed as information can be improperly formatted or contain incorrect data.

Routers can also run out of memory or storage or be too slow to respond to updates. Routers send error codes and subcodes to communicate problems, including timeouts, malformed requests and processing problems.

Facebook outage

On Oct. 4, 2021, social media applications Facebook, Instagram and WhatsApp went offline for six hours. The outage was reportedly due to there being no working BGP routes into the social media sites and the domain name servers going offline. This essentially disconnected the social media apps from the internet.

BGP security

BGP is also vulnerable to attacks based on misinformation. Malicious actors can flood a router with bad packets in a denial-of-service attack, for example. They can also claim to be the source of routing information for an AS and temporarily control where traffic headed from that AS goes, a practice known as BGP hijacking.

Difference between internal and external BGP, OSPF

BGP that is used to route within a single AS is iBGP. When BGP is used to connect one AS to others, it is called External BGP, or eBGP.

The Open Shortest Path First (OSPF) protocol is used only in internal networks. OSPF focuses on finding the shortest route available between nodes and on failing over to that shortest route as quickly as possible.

A comparison of BGP and OSPF use cases in network environments
BGP works well for internet redundancy, WAN environments and IaaS. OSPF is useful for the LAN and data center.

BGP is slower to fail to a new route but more scalable than OSPF. As such, OSPF is better suited for corporate local area networks and private data centers. OSPF is essentially hierarchical in structure, while BGP is a mesh. Some networks are replacing OSPF with iBGP.

Editor's note: This definition was updated to add BGP information and improve the reader experience.

This was last updated in June 2023

Continue Reading About BGP (Border Gateway Protocol)

Dig Deeper on Network Infrastructure

Unified Communications
Mobile Computing
Data Center