Border Gateway Protocol: An introduction to the Routing Protocol of the Internet!

Border Gateway Protocol: An introduction to the Routing Protocol of the Internet!

In previous blogs, we discussed OSPF, an internal gateway protocol (IGP) that distributes routing information within a single Autonomous System (AS). An AS is a network or group of networks managed by a single entity, like a company or government. However, the internet is formed by the interconnection of these different ASes. The routing protocol that enables communication between these diverse networks is the Border Gateway Protocol (BGP). BGP plays a crucial role in facilitating internet connectivity, making it essential to understand its workings for anyone interested in networking.

BGP is an External Gateway Protocol (EGP) specifically designed for routing between multiple Autonomous Systems. Unlike IGPs that focus on optimal paths within a single AS, BGP considers the entire path to a destination network across multiple ASes. This is known as path vector routing, where each router advertises not just the next hop, but the complete path to reach a destination. This allows BGP to make informed routing decisions based on factors like policy, performance, and commercial agreements between ASes.

BGP relies on TCP for accurate and ordered delivery of routing information, using port 179. Think of it as a reliable postal service, ensuring that routing updates are delivered intact and in the correct order.

Although generally considered an EGP, BGP has two flavors:

  • EBGP (External BGP): The default EGP used for routing between different ASes. It has an administrative distance of 20, making it a preferred routing protocol.
  • IBGP (Internal BGP): An IGP version of BGP used for distributing routing information within an AS. It has an administrative distance of 200.

BGP is widely used by internet service providers (ISPs) to exchange routing information and ensure that internet traffic can reach its destination. Large enterprises also use BGP to connect their different branches and data centers across multiple ASes.

With its ability to handle complex routing scenarios and manage traffic across multiple ASes, BGP is a powerful tool for network administrators. However, it's essential to understand when it's the right choice for your network and when other routing protocols might be more suitable. Let's explore the scenarios where BGP shines and where it might not be the best fit.

When should I use BGP?

BGP is primarily used in the following scenarios:

  • Transit Autonomous System (AS): A transit AS acts as an intermediary between multiple ASes, allowing them to exchange traffic. BGP enables the transit AS to learn routes from its connected ASes, advertise its routes, and control traffic flow. Examples of transit ASes include Internet exchange points (IXPs), Internet service providers (ISPs), large organizations connecting to multiple other organizations.
  • Multihoming: Multihoming is when an AS connects to multiple ISPs for redundancy and improved performance. BGP allows the AS to receive routes from multiple ISPs, advertise its prefixes, control outbound traffic, and failover to a different ISP in case of an outage. With BGO we have the advantage of load balancing and failover between ISPs

When not to use BGP?

While BGP is a powerful routing protocol, it's not always the best choice for every network. Here are some scenarios where you might want to consider alternative solutions:

  • Single-homed and Dual-homed Sites: If your AS is connected to only one or two ISPs, BGP might be overkill. A simpler solution like static routing or a dynamic routing protocol like RIP might be sufficient for managing your routing needs.
  • Limited Resources: BGP can be resource-intensive, requiring significant memory and processing power. If your network devices have limited resources, especially older or less powerful devices, BGP might not be the best option. Consider using a less demanding routing protocol like RIP or OSPF in such scenarios.
  • Limited BGP Knowledge: BGP is a complex protocol that requires specialized knowledge to configure and manage effectively. If you lack the expertise to properly implement and maintain BGP, it's best to avoid it. Misconfigurations can lead to routing instability and network outages. Opt for a simpler protocol or seek assistance from experienced network engineers.

Understanding BGP Neighbors

BGP neighbors, also known as BGP peers, are routers that establish TCP connections to exchange routing information. These connections are the foundation of BGP routing, enabling routers to learn about reachable networks and make informed routing decisions.

Why Manual Configuration?

BGP neighbors must be manually configured to establish trust relationships and prevent unauthorized routing updates, ensuring network stability.

Types of BGP Neighbor Relationships

  • Internal BGP (IBGP): Formed between routers within the same AS.
  • External BGP (EBGP): Formed between routers in different ASes.

BGP Databases

BGP has multiple rules that govern its operation, and the data used is stored in different BGP databases. The following are some key databases

Neighbor Table

Purpose: list of all configured BGP neighbors

Information: Neighbor IP addresses, AS numbers, status, timers

Command: show ip bgp summary, show ip bgp neighbors

BGP forwarding table/database

Purpose: A list of networks known by BGP, along with their paths and attributes

Information: Network Prefixes, AS_PATH, Origin, MED, Local Preference

Command: show ip bgp

IP routing table

Purpose: List of best paths to destination networks from all routing protocols

Information: Destination network, next hop IP address, routing protocol

Command: show ip route

How does BGP handle authentication?

BGP utilizes the underlying TCP protocol for authentication, leveraging its inherent ability to establish secure connections and ensure reliable data delivery. By relying on TCP's MD5 authentication mechanism, BGP avoids the complexity of building a separate authentication framework, allowing it to focus on its routing responthat sibilities

When BGP authentication is enabled, each TCP segment carrying BGP information exchanged between peers undergoes a verification process. This authentication process relies on a shared secret password configured on both peer routers. Only if the authentication is successful will the BGP peers establish a neighbor relationship and exchange routing information. If authentication fails, the BGP session will not be established, preventing unauthorized routers from participating in the routing process.

How does BGP prevent loops between ASes (EBGP)?

BGP utilizes a crucial attribute known as the AS_PATH to prevent routing loops. The AS_PATH contains the AS number of every Autonomous System (AS) it has passed through. When a BGP update message is received, the router checks the AS_PATH to verify that its own AS number is not included. If its AS number is included, the router rejects the update, preventing the routing information from circulating back to an AS it has already traversed. This mechanism is how BGP primarily creates a stable and loop-free network.

How does BGP prevent loops within an AS (IBGP)?

BGP has multiple mechanisms to prevent loops in an AS when running the IBGP flavor. Some include

Split Horizon: This is a fundamental principle in BGP that prevents loops within an AS. It says that an update sent by one IBGP neighbor should not be sent back to the same IBGP neighbor. In simple words, If router A sends a route to router B, router B cannot send that route back to router A.

Full Mesh: In this topology, all routers form neighbor relationships with all routers in the same AS even if the routers are not physically connected. This helps for complete route visibility and has direct peering sessions with every other router therefore preventing loops. 

However, full mesh IBGP has scalability challenges. As the number of routers in an AS increases, the number of required peering sessions grows significantly, leading to increased configuration overhead and potential management complexity. Additionally, each router needs to store a complete copy of the BGP routing table, which can lead to high memory consumption, especially in larger networks. Due to these scalability concerns, full mesh IBGP is typically recommended only for ASes with a small number of routers (generally 4-5).

Route Reflectors and Cluster Lists: This is a scalable alternative to an iBGP full mesh. The concept is similar to designated routers in OSPF where route advertisement is done using a server-client model. All client peers communicate routes to the route reflector, and the route reflector advertises these received routes to other routers in the AS. iBGP routers would only establish peering sessions with the route reflectors. It is good to note that route reflectors do not originate routes but only reflect them.

In this setup, BGP then makes use of cluster lists to prevent loops. Each router reflector has its unique cluster ID, and it adds it to the route attributes when it advertises a route. The router then checks for the cluster ID of every route it receives, and if it sees its own route reflector’s cluster ID, it knows it has already advertised this route and doesn’t send it back to the route reflector. This is similar to loop prevention by AS_PATH with EBGP

What is the BGP synchronization rule?

The BGP synchronization rule is a mechanism designed to ensure consistency between the Interior Gateway Protocol (IGP) and BGP routing tables within an Autonomous System (AS). It enforces the following principle:

A BGP router should not use or advertise to an external neighbor a route learned via IBGP until a matching route has been learned from an IGP. This ensures consistency of information throughout the AS.

This rule helps ensure that routes given to external peers must have a corresponding IGP route to prevent network blackholing. This rule can be disabled when there is a full mesh IBGP, as all IBGP routers would have full visibility of internal routes, or if the AS in question doesn’t have any transit traffic.

Conclusion

I believe this blog has provided a comprehensive introduction to BGP, covering its core functions, operational mechanisms, and significance in internet routing. We've explored key concepts such as BGP neighbor relationships, loop prevention mechanisms, and the synchronization rule, all of which are crucial for understanding how BGP ensures efficient and reliable communication between different networks.

In the next blog post, we'll delve deeper into BGP attributes, further expanding your knowledge of this essential routing protocol. Stay tuned for a more in-depth exploration of BGP and its role in shaping the internet landscape!