BGP Explained with Examples.

By | November 26, 2023

Understanding the Border Gateway Protocol (BGP)

The Border Gateway Protocol (BGP) is a sophisticated and advanced distance-vector routing protocol, often categorized as an Exterior Gateway Protocol (EGP). In various sectors, it has earned the moniker of the “big dog” of internet protocols.

Interaction Between Autonomous Systems

BGP facilitates the exchange of routing information between different Autonomous Systems (ASs). This sets it apart from Interior Gateway Protocols (IGPs) such as Routing Information Protocol (RIP), Enhanced Interior Gateway Routing Protocol (EIGRP), and Open Shortest Path First (OSPF), which typically operate within a single organizational network.

Path Selection Algorithm

Unlike IGPs, BGP employs a Best Path Selection Algorithm (BPSA) to identify and populate the most optimal routes into a router’s routing table. This algorithm serves as a fundamentally distinct approach to constructing a loop-free network topology compared to the aforementioned IGPs.

Applications of BGP

BGP plays a critical role in routing information exchanges between major Internet Service Providers (ISPs). It is also instrumental for larger client sites in their interactions with their respective ISPs. In certain expansive enterprise networks, BGP is utilized to link various geographical or administrative regions.

Cisco’s Implementation and Features

Primarily designed to accommodate the complexities of the public internet, Cisco has enhanced its BGP implementation, known as BGP-4, with several ingenious and practical features.

Primary Attributes

One of the defining attributes of BGP is its use of mandatory information pieces concerning known routes. These pieces include the origin of the route and the methods to reach it. Furthermore, a BGP router is configured to generate an error message if it encounters a missing route.

bgp1

Comprehensive Overview of Border Gateway Protocol (BGP)

Types of BGP

BGP can be broadly categorized into three different types, each serving a specific function within or between Autonomous Systems (AS):

Internal BGP (iBGP): This operates within a single Autonomous System (AS). It facilitates internal route propagation and ensures that routers within the AS have complete and consistent routing information.

External BGP (eBGP): Also referred to as an inter-domain routing protocol, eBGP operates outside an AS and connects one AS to another. While it utilizes the same underlying BGP protocol, the scope of its operation differentiates it from iBGP.

Multiprotocol BGP (MP-BGP): This is an extension of BGPv4 and is primarily designed to support IPv6 routing, alongside other network protocols.

Autonomous Systems (AS)

An Autonomous System can encompass various entities, such as a company, an Internet Service Provider (ISP), or an entire corporate network spread across multiple locations. Within each AS, BGP is used for two primary purposes:

To advertise routes within the network that should be accessible externally.

To acquire information about external reachability and routes by listening to announcements from other ASs.

Each AS is identified by an Autonomous System Number (ASN), which facilitates hierarchical organization during route information exchange. There are 65,536 available ASNs, ranging from 0 to 65,535. Of these, the numbers 64,512 to 65,534 are designated as private ASNs. A private ASN usually connects to just one or sometimes multiple ASNs but is configured in a manner to avoid routing loops.

BGP Update Messages.

BGP is unique in the volume and complexity of the routing information it exchanges, far exceeding that of Interior Gateway Protocols (IGPs). For instance:

Routing Information Protocol (RIP): A simple IGP, primarily carries basic attributes like metric information and the next hop.

Open Shortest Path First (OSPF): A more sophisticated IGP, that supports path attributes such as intra-area, inter-area, and external statuses.

In contrast, BGP can attach multiple attributes to a single route. The minimal set of attributes in a BGP update message includes the source of the update, termed the ORIGIN attribute, and the Autonomous System Path, known as the AS_PATH attribute.

BGP Operational Mechanics

When two routers running BGP initiate communication for dynamic routing information exchange, they utilize TCP port 179 at Layer 4 of the OSI Reference Model. This specificity allows BGP to rely on TCP to ensure the orderly and reliable delivery of messages.

The routers involved in this communication are termed BGP peers or neighbours, and their reliable, connection-oriented interactions are called sessions. A BGP router that advertises routes is known as a BGP speaker. The advertised routes are deemed valid until either explicitly invalidated or the TCP session is terminated.

BGP Session States

Idle State: Before session initiation, the endpoints are in this state.

Connection State: Upon attempting to open a TCP session, an endpoint enters this state.

Active State: If the connection encounters issues, the router will transition to this state, where it periodically attempts to re-establish the session.

Once the TCP session is successfully established, a reliable path between endpoints is assured, permitting efficient and reliable message exchanges.

Types of BGP Messages:

Open: This is to establish a peering/ neighbor’s or endpoint router sessions

+ Keep-Alive: message type in a common header to allow routers to verify when sessions are active.

+ Notification: shuts down a peering session

+ Update: Announcing new routes or withdrawing previously announced routes

BGP must rely on the connection-established TCP session to provide the Connection state because BGP doesn’t use a keepalive signal but sends a message with a KEEPALIVE type in a common header to allow routers to verify when sessions are active.

Unlike the Standard keepalives signals sent from one router to another on a circuit not using a TCP session. BGP routers use these signals on circuits to verify connectivity on the circuit.

Once the TCP connection has been established, BGP sends and receives messages in a specific format. The first message is an identification message from the endpoints, peers or BGP neighbours.

When a BGP router sends a message, the router changes to OpenSent state.

When the router receives a reply to the identification message, it changes to the OpenConfirm state.

If a connection is received and accepted by the endpoints, the Connection state becomes the Established state.

From then on, when a message is sent to the endpoint routers, the routers can respond to the sent message, update their routing table with new information in the message, or have no reaction to the sent message whatsoever.

Endpoints typically stay in the Established state until there is a loss of the session or an error. If this occurs, then the connection returns to the Idle state and all the information that the BGP endpoints have learned from their neighboring endpoint will be purged from the BGP routing table.

Characteristics of BGP-4

The key features of BGP-4 include and not limited to these:

• It is an advanced distance-vector protocol.

• BGP sends full routing updates at the start of the session, trigger updates are sent afterward.

• BGP maintains a connection by sending periodic keepalives.

• It creates and maintains connections between peers, using TCP port 179.

• BGP sends a triggered update when a keepalive, an update, or a notification is not received

• It has its own routing table, although it is capable of both sharing and inquiring of the interior IP routing table.

• BGP uses a very complex metric and is the source of its strength. The metric, referred to as attributes, allows great flexibility in path selection.

How to Configure BGP Using Loopback Address

How To Authenticate MD5 for BGP Peers

How To Configure eBGP Multihop