Introduction

Border Gateway Protocol (BGP) is a standardized exterior gateway protocol used to manage the routing and exchange of routing information between autonomous systems (ASes) on the Internet. An autonomous system is a collection of IP networks and routers under the control of a single organization that presents a common routing policy to the internet.

Description
Routing Between Autonomous Systems: BGP is specifically designed for routing between different autonomous systems. It helps in determining the best path for data packets to traverse from one AS to another. This is essential for maintaining the global connectivity of the Internet.
Path Vector Protocol: Unlike interior gateway protocols (IGPs) such as OSPF and RIP, which use distance-vector or link-state algorithms, BGP is a path vector protocol. It maintains a list of autonomous systems that a route has traversed before reaching its destination. This information helps in avoiding routing loops and making routing decisions based on policy.
Policy-Based Routing: BGP allows network administrators to define routing policies based on various criteria such as AS path length, prefix attributes, and more. This policy-based routing enables organizations to have fine-grained control over how their traffic is routed.
Path Selection: BGP selects the best path for a destination based on a set of attributes associated with each route. Some of the key attributes include AS path length, next-hop IP address, and local preference. Network administrators can influence the path selection process by manipulating these attributes.
Neighbor Relationships: BGP routers establish neighbor relationships with other BGP routers in neighboring autonomous systems. These relationships are typically manually configured and rely on the Transmission Control Protocol (TCP) for reliable communication.
Route Advertisement: BGP routers exchange routing information with their neighbors by advertising routes. When a BGP router learns about a new route or withdrawal of a route, it informs its neighbors by sending BGP update messages.
Route Aggregation: BGP allows for the aggregation of multiple IP prefixes into a single prefix, known as route summarization or aggregation. This helps in reducing the size of the BGP routing table and improving scalability.
Loop Prevention: BGP uses the AS path attribute to prevent routing loops. If a BGP router receives a route update that contains its own AS number in the AS path, it will reject the route to avoid a loop.
Security: BGP has been vulnerable to various security threats, including prefix hijacking and route leaks. To mitigate these risks, various mechanisms and standards like BGPsec (BGP Secure Routing) have been developed to enhance the security of BGP routing.

Additional information about BGP:

Description
BGP uses the TCP port 179 to communicate with other routers, it is no multicast routing protocol, only unicast.
BGP is a path-vector routing protocol, therefore it counts AS hops
If the local router and the remote router are configured with the same AS number, the protocol becomes iBGP with an administrative distance of 200 (interior).
If the local router and the remote router are configured with different AS numbers, the protocol becomes eBGP with an administrative distance of 20 (exterior).
BGP selects automatically the highest IP address on the system as router ID, but it is recommended to configure the ID manually.
BGP supports a 2-byte AS number, and also a 4-byte AS number.
The 2-byte ASN ranges from 1-65535 (1-65411 = public / 65412-65535 = private).
The 4-bye ANS is displayes as a decimal number (0.1, 1.0, etc.).
BGP uses attributes as weight, cs-path, local preference.
AS numbers (32 bits) are assigned by IANA, and there are 4.3 billion unique AS numbers available.
BGP routers use adjacencies to exchange routes, but routers do not have to be directly connected to establish adjacencies.
An established adjacency between BGP peers is called a BGP session.
BGP allows adjacencies between peers that are multiple hops away.
Multi-hop sessions require underlying routes from RIB.
Neighbor addresses need to be configured explicitly, they are not learnt via multicast.
BGP advertisements contain contain the address prefix and length.
The NLRI (Network Layer Reachability Information) contains BGP advertisements information and PAs (Path Attributes).

BGP States

Border Gateway Protocol (BGP) operates through a series of states that help establish and maintain neighbor relationships between BGP routers. These states are part of the BGP finite state machine and ensure proper communication and route exchange. BGP has six primary states:

Description
Idle State: This is the initial state when the BGP process starts or when a BGP router is reset. In the Idle state, the router doesn't send or receive BGP updates, and it doesn't establish BGP neighbor relationships. The router transitions to the Connect state if it attempts to establish a connection with a neighbor.
Connect State: In this state, the router tries to establish a TCP connection with its BGP neighbor. The TCP three-way handshake process takes place, and if successful, the router moves to the OpenSent state. If the connection attempt fails, it returns to the Idle state.
OpenSent State: After successfully establishing a TCP connection, the router transitions to the OpenSent state. In this state, the router sends an OPEN message to its neighbor, containing parameters and capabilities. If the neighbor accepts the OPEN message and its parameters match, it responds with an OPEN message of its own, and the router moves to the OpenConfirm state.
OpenConfirm State: In the OpenConfirm state, the router has received an OPEN message from its neighbor and is waiting for the TCP connection to stabilize. It ensures that the neighbor is reachable and that the connection is reliable. Once confirmed, the router transitions to the Established state.
Established State: This is the fully established BGP neighbor relationship state. In the Established state, BGP routers exchange routing information and keep the connection active by periodically sending KEEPALIVE messages. They also exchange UPDATE messages to advertise and withdraw routes. Routes learned from the neighbor are added to the BGP routing table.
Idle (Admin) State: This is a special state that can be manually triggered by a network administrator. When a BGP router is in the Established state, it can be administratively reset to the Idle state without waiting for any automatic BGP events. This can be useful for making configuration changes or troubleshooting BGP issues.

BGP Message Types

Border Gateway Protocol (BGP) uses various message types to exchange routing information and maintain neighbor relationships between BGP routers. These messages are a fundamental part of the BGP protocol. Here are the primary BGP message types:

Description
Open Message (Type 1): The Open message is the first message sent when two BGP routers are establishing a connection. It contains information about the sender, such as its AS number, BGP version number, and optional capabilities. The Open message helps the routers agree on the parameters for their BGP session. If the parameters match and the neighbor is acceptable, the routers proceed to exchange routing information.
Update Message (Type 2): The Update message is used to exchange routing information and is the most important BGP message type. It carries information about routes, including prefixes, AS paths, attributes, and route withdrawal information. When a BGP router learns about new routes or changes in existing routes, it sends Update messages to its neighbors to share this information. This message type plays a central role in BGP route propagation.
Notification Message (Type 3): The Notification message is used to report errors and issues during the BGP session. When a BGP router encounters a problem, such as an incorrect parameter in the Open message or a misconfiguration, it sends a Notification message to its neighbor to signal the issue and terminate the BGP session. This message helps in identifying and diagnosing problems in the BGP configuration.
Keepalive Message (Type 4): The Keepalive message serves to maintain the BGP session and confirm that the connection is still active. BGP routers periodically exchange Keepalive messages to ensure that their neighbor is reachable and the connection is reliable. The absence of Keepalive messages for a specified period can lead to the termination of the BGP session.
Route-Refresh Message (Type 5): The Route-Refresh message is used to request the re-advertisement of BGP routes from a neighbor. This message is part of the BGP Route Refresh capability, which allows a BGP router to request the re-advertisement of all its received routes without tearing down the BGP session. It helps in refreshing and updating BGP routes without causing disruptions.

BGP Path Attributes

Border Gateway Protocol (BGP) uses path attributes to convey various types of information about routes, including how to reach a particular destination, and to influence route selection and policy decisions. BGP path attributes are included in BGP update messages and help BGP routers make informed routing decisions. Path attributes can be categorized into two main types: well-known and optional attributes.

Description
Attributes
Well-Known Path Attributes: Well-known path attributes are essential and must be recognized and supported by all BGP routers. They are divided into two subcategories: mandatory and discretionary.
Mandatory Attributes: AS Path (AS_PATH): This attribute records the sequence of autonomous systems (ASes) that the BGP route has traversed. It helps in loop prevention and provides information about the route's history. AS Path is mandatory, and it must be included in BGP updates. Next Hop (NEXT_HOP): This attribute specifies the IP address of the next-hop router to reach the destination network. It is crucial for route forwarding, and it is mandatory.
Discretionary Attributes: Local Preference (LOCAL_PREF): Local Preference is used within an autonomous system to influence route selection. It is not advertised to external BGP peers. Higher values indicate a more preferred route. Multi-Exit Discriminator (MED): MED is used to influence route selection for inbound traffic when multiple BGP routers advertise routes to the same destination. Lower MED values are preferred by BGP routers.
Optional Path Attributes: Optional path attributes are not mandatory for all BGP routers to support and are used to provide additional information or influence route selection and policy. They are divided into transitive and non-transitive attributes.
Transitive Attributes: Transitive attributes are passed to BGP routers, even if they don't recognize them. If a BGP router doesn't understand a transitive attribute, it will forward it to the next BGP peer. Community (COMMUNITY): The Community attribute is used to tag routes with labels that can carry additional information or policies. Communities can be used to influence routing decisions within or between ASes. Extended Communities (EXTENDED_COMMUNITY): Extended Communities are similar to standard communities but provide more flexibility and information for routing policies. Large Community (LARGE_COMMUNITY): Large Communities are an extension of standard communities and provide even more flexibility and information for routing policies.
Non-Transitive Attributes: Non-transitive attributes are not passed to BGP routers that do not recognize them. If a BGP router doesn't understand a non-transitive attribute, it will remove it from the update before forwarding it. Aggregator (AGGREGATOR): The Aggregator attribute provides information about the AS that performed route aggregation. It helps in identifying where the aggregation occurred. Atomic Aggregate (ATOMIC_AGGREGATE): This attribute is used to indicate that a BGP router has aggregated multiple prefixes into a single route, which may result in loss of specific route information.

Path Selection Algorithm

The BGP (Border Gateway Protocol) path selection algorithm, often referred to as the BGP Best Path Selection Algorithm, is a set of rules that BGP routers use to determine the best path to reach a particular destination network. BGP routers consider various path attributes and information to make informed routing decisions. The following is a step-by-step explanation of the BGP path selection algorithm:

Description
Path with the Highest Weight: BGP routers may use a local attribute called "weight" to prefer one route over another. The weight is not a standard BGP attribute but is specific to the router's configuration. Routes with higher weights are preferred.
Local Preference (LOCAL_PREF): BGP routers within the same autonomous system (AS) use the Local Preference attribute to influence the selection of exit points for outbound traffic. A higher Local Preference value makes a route more preferred.
AS Path Length: BGP routers prefer routes with shorter AS paths. The AS path is a mandatory attribute that records the sequence of autonomous systems a route has traversed. Shorter paths indicate fewer intermediate hops, making the route more attractive.
Origin Type (ORIGIN): BGP routes can have three possible origin types: IGP (Interior Gateway Protocol), EGP (Exterior Gateway Protocol), or Incomplete. BGP routers prefer routes with the origin type set to IGP over EGP and Incomplete.
Multi-Exit Discriminator (MED): If multiple paths to the same destination exist and are advertised by different autonomous systems, the Multi-Exit Discriminator (MED) is considered. Lower MED values are preferred, assuming the paths are from different ASes.
eBGP over iBGP: If a BGP router has multiple paths to the same destination, it will prefer external BGP (eBGP) routes over internal BGP (iBGP) routes. This rule ensures that eBGP-learned routes are favored over iBGP-learned routes.
Shortest IGP Path to BGP Next Hop: When multiple paths with the same attributes exist, the BGP router considers the shortest IGP (Interior Gateway Protocol) path to reach the BGP next hop. This rule is used to prefer routes that are physically closer in the network.
Router ID: If all else is equal, BGP routers may use the BGP router's Router ID as a tiebreaker. The Router ID is typically the highest IP address on the router.
Lowest Neighbor IP Address: In the rare case that all other factors are still equal, the BGP router may use the lowest neighbor IP address as a final tiebreaker.

Premium Access

Log in or register - Premium members can access all content without restrictions.

Get Premium

0 Comments

Submit a Comment