What Is Border Gateway Protocol (BGP)?
Many network protocols have been created to support communication between computers. These protocols, called routing protocols, determine how data transfers across networks. One popular routing protocol you’ll encounter in a modern network environment is the Border Gateway Protocol (BGP). In this article, learn what BGP is, how it works, and its importance.
What is Border Gateway Protocol in networking?
Border Gateway Protocol, or BGP, is a standardized routing protocol used to exchange routing information across autonomous systems (ASes) on the global Internet. Its function is to find the best paths for data packets to travel among complex networks.
The Internet is a network of smaller networks known as autonomous systems. A single administrative entity, such as an Internet service provider, manages each of these networks. These networks are like a group of routers that help link different parts of the Internet together.
Each system involved in exchanging routing information must have a unique registered autonomous system number (ASN). The networks connect together through standardized protocols, devices, and communication technologies.
When you use the Internet, your data has to pass through several networks before it gets to its final destination. The BGP protocol looks at all possible routes and picks the best one for the data to follow. For example, if someone in the United States is using an app with servers in Europe, Border Gateway Protocol makes sure the data travels efficiently from one place to the other.
BGP is a "path-vector protocol," which means it chooses the best one based on rules received from the network administrators. It provides “reachability information” among Autonomous Systems (ASes).
Reachability in this case means the ability of a network device to communicate with another device over the Internet. Reachability information tells the routers if a particular network can be reached, and if so, how to send data to it.
Border Gateway Protocol routers share information about the paths that data can use to get to different places on the Internet. The protocol operates at the transport layer (Layer 4) of the OSI model, but it controls the routing decisions on the network layer (Layer 3).

Border Gateway Protocol history and versions
The Border Gateway Protocol has a long history, beginning in the 1980s when the Internet was still new. Back then, routing was simple and worked within individual networks. But as the Internet grew, it became clear that a better routing system was needed to handle the large number of networks connecting across the globe.
The year 1989 introduced the first version of BGP (BGP-1). It replaced the old Exterior Gateway Protocol (EGP) as it could no longer meet the needs of the expanding Internet. BGP-1 made it easier for autonomous systems to connect and share routing information.
In later years, engineers released new versions to improve the protocol. BGP-2 added support for Classless Inter-Domain Routing (CIDR), which allowed better management of IP addresses. This made it easier to divide networks into smaller blocks. BGP-3 introduced better error handling and route aggregation to improve the protocol’s reliability.
The most important update came in 1994 with BGP-4. The version included many key improvements, such as the ability to handle multiple network protocols (like IPv4 and IPv6) at once through Multiprotocol BGP (MBGP). It also added security features, such as the MD5 authentication mechanism, to protect Border Gateway Protocol sessions from unauthorized access.
Since then, BGP-4 has been updated with additional features, like BGP/MPLS IP VPNs, BGP FlowSpec, and BGPsec, to improve its capabilities. Unfortunately, the main structure and principles of BGP-4 have remained unchanged. It is still the version used today for routing between different networks on the Internet.
Features of Border Gateway Protocol
Border Gateway Protocol enables different Internet networks to communicate with each other. Here are the key operating attributes that make BGP so important.
- Path-vector protocol. BGP is a "path-vector" protocol. This means it keeps track of the full route information, including which networks (Autonomous Systems) the data passes through.
- Operates at the edges of networks. The protocol works at the edges of networks to connect different autonomous systems. This gives it a broad view of the Internet's routing system.
- Inter-autonomous system communication. BGP allows different autonomous systems to talk to each other. Without it, these systems would remain isolated.
- Supports next-hop paradigm. Border Gateway Protocol uses the "next-hop" method to decide where to send data. Instead of choosing the farthest or least efficient router, BGP chooses the best next step so that data moves faster.
- Path information. BGP advertisements contain path information that tells routers the next destination. Routers decide the best route to take.
- Policy support. BGP allows network administrators to create custom routing policies. For example, they can decide which routes within their own system are preferred over routes outside the system.
- Runs over TCP. It uses the Transmission Control Protocol (TCP) to send messages. Since most Internet traffic also uses TCP, this ensures BGP works well with other protocols like SSL, VPN, and TLS for secure connections.
- Conserves network bandwidth. The BGP protocol saves network bandwidth. It is the most efficient path for data to travel. From this, the network can handle more traffic without slowing down.
- Supports CIDR. BGP works well with Classless Inter-Domain Routing (CIDR), which helps manage IP addresses more efficiently. Because of this, BGP doesn’t interfere with IP assignment or management, making the system more flexible.
How does Border Gateway Protocol work?
Border Gateway Protocol works using a process called peering. BGP peering refers to the process by which two BGP routers establish a connection to exchange routing information. The routers involved in peering are called BGP peers or BGP neighbors.
Peering relationships among routers allow the exchange of routing updates. Each BGP router shares its own routing table and receives routing updates from its peers.
BGP routing process involves the following steps.
Step one: Session establishment
BGP peers must establish a TCP connection on port 179 between each other to begin communication. The routers need to establish a connection before exchanging routing information. This routing information is kept in a Routing Information Base (RIB).
Administrators configure the IP addresses of the peers on both routers manually. BGP does not automatically discover neighbors, so each router must work with the IP address of its peer.
The BGP open message is sent to initiate the connection and synchronize the session. This message includes information like the BGP version, Autonomous System Number (ASN), BGP router, ID and other capabilities.
Step two: Route advertisement
Once the session is established, the routers begin exchanging BGP updates. These updates contain important routing information about how to reach various destinations. Each update includes:
- Prefix information, which specifies the network prefixes or IP addresses that the router can reach.
- Older path, a list of Autonomous Systems (ASes) that the route has traversed. It prevents routing loops by showing the history of the path.
- Next hop indicates the IP address of the next router to which data should go in order to reach the destination.
- Various path attributes, such as local preference (indicates how preferred a route is within the AS), Multi-Exit Discriminator (MED) (determines the preferred entry point to an AS when multiple options are available), origin (indicates where the route originated), and others.
With these updates, each router learns about the network’s topology.
Step three: Route selection
After receiving routing information, BGP uses several criteria to determine the most optimal path. The router evaluates various attributes to select the best route.
- Local preference: This value is set by an AS to prefer certain routes over others. Higher local preference indicates a preferred route.
- Shortest AS path: The path that passes through the fewest ASes is usually preferred. Shorter paths tend to be more efficient.
- Lowest origin type: BGP prefers routes that originated within an IGP (Interior Gateway Protocol) over those that originated from EGP (Exterior Gateway Protocol) sources.
- Lowest Multi-Exit Discriminator (MED): If multiple entry points to the AS exist, BGP prefers the path with the lowest MED.
- EBGP over IBGP: Routes learned via External BGP (EBGP) work better than those learned via Internal BGP (IBGP) within the same AS.
- Tie-breaking: If all other criteria are equal, BGP will break ties by selecting the path with the lowest router ID or the lowest IP address.
These rules help BGP make informed decisions about the most efficient route for data, ensuring that traffic flows in the best possible direction.
Step four: Routing table updates
Once the best route is determined, it is placed in the router's BGP routing table, and the router uses this table to forward packets. The routing table contains not just the best route but also backup routes.
Step five: Propagation
When a router learns a new path, it advertises that path to its BGP neighbors (other ASes). This process of propagating routing updates continues across the Internet.
BGP uses these rules to make informed decisions about the most efficient route for data.
Border Gateway Protocol path attributes
Border Gateway Protocol updates routing information only when the network changes. It doesn't send the whole routing table every time - just the updated parts.
There are several features that define Border Gateway Protocol. It makes best-path decisions based on these key attributes, such as:
- AS path. This is a list of AS numbers that the route has passed through.
- Hop counts. Specifies the next hop IP address to reach the destination network.
- Local preference. A value that lets BGP routers within the same AS choose preferred exit points.
- Origin. Indicates where the route originated (whether from IGP, EGP, or unknown).
- Community. A tag that can be used for grouping prefixes for easier management.
Types of Border Gateway Protocol
BGP is typically categorized into two types: internal and external. External BGP, or EBGP, works for communication between routers in different ASes. It's the most common form of Border Gateway Protocol and is responsible for exchanging routing information between ISPs or between an ISP and its customers.
Internal BGP, or IBGP, connects routers within the same ASes. IBGP routers do not advertise routes to external peers but share Border Gateway Protocol routing information internally within the AS.
Example of Border Gateway Protocol
Let’s walk through a simple example to illustrate how BGP works in action:
- Router A in AS 1 wants to send a packet to Router B in AS 2.
- Router A learns through BGP that the destination network in AS 2 can be reached via Router C in AS 3.
- Router A propagates the information to Router D, and Router D in AS 4 learns how to reach AS 2 via Router C.
The routers propagate these updates so that each router in the path can forward packets in the most efficient way possible.
Why is BGP important?
BGP peering is essential for several reasons:
- Policy control. Peering gives network operators control over routing policies. Through the use of prefix lists, route maps, and AS path filters, operators can influence how traffic enters or exits their network.
- Redundancy and reliability. Having multiple BGP peers provides redundancy. If one peer or route fails, the network can automatically shift to another available path.
- Scalability. The ability to form peering relationships between networks is what allows the Internet to scale to handle millions of routes.
- Route propagation. Peering allows routers to exchange information about the reachable network prefixes across the internet.
Challenges of Border Gateway Protocol
While BGP is powerful, it also faces challenges, particularly in terms of security. Mistakes in configuring Border Gateway Protocol routers can lead to unintended routing behavior that may cause traffic drops. Furthermore, malicious actors can advertise prefixes that they do not own, causing traffic to divert through them.
Border Gateway Protocol also faces the issue of route leaks, where incorrectly advertised routes lead to suboptimal routing. Ultimately, the protocol has benefits, but you must use it properly in order to prevent delays or security concerns.
Use cases and applications of Border Gateway Protocol
Large-scale networks, like those used by Internet service providers (ISPs), rely on BGP to organize data efficiently. Routers share information to ensure traffic flows smoothly even in complex systems.
When a network connects to multiple ISPs, BGP plays a critical role in multi-homing. It directs traffic along the most reliable route. If one ISP fails, BGP automatically switches to the backup for continuous service.
Another key function of Border Gateway Protocol is load balancing. It spreads traffic across several routes to prevent any single path from becoming overloaded. As a result, the network stays responsive even during peak usage times.
Frequently asked questions
What is the main purpose of Border Gateway Protocol?
The primary function of BGP (Border Gateway Protocol) is to provide communication between two autonomous systems.
Who uses BGP technology?
Internet Service Providers (ISPs) are the main users of BGP. Others include companies with large network operations, Content Delivery Networks (CDNs), cloud service providers, and data center operators.
What happens if BGP fails?
The Internet routing breaks down, causing connectivity loss, traffic blackholes, widespread outages, and disrupted services globally.