Border Gateway Protocol (BGP) is a crucial routing protocol used to exchange routing information between routers in different autonomous systems (AS) on the Internet. As a network engineer pursuing the CCNP certification, it's important to have a solid understanding of BGP and its key concepts.
BGP works by advertising the complete list of IP prefixes within an autonomous system to its neighboring routers. This information allows routers to build a complete picture of the Internet routing topology and to determine the best path to reach a particular destination. BGP is widely used by service providers and large enterprises to exchange routing information and provide internet connectivity to their customers.
The key concepts of BGP include:
Autonomous System (AS): An AS is a collection of interconnected IP routing prefixes under the control of a single administrative entity.
BGP neighbors: BGP neighbors are routers that have established a BGP session and are exchanging routing information.
BGP attributes: BGP attributes are properties of a BGP route that influence the selection of the best path to a destination. Examples of BGP attributes include local preference, AS path length, and next-hop IP address.
BGP best path selection: BGP uses a combination of attributes to determine the best path to a destination. The path with the highest value of the composite metric is selected as the best path.
BGP peering: BGP peering refers to the process of establishing a BGP session between two routers. BGP peering enables the exchange of routing information between routers in different autonomous systems.
BGP communities: BGP communities are attributes that can be added to a BGP route to allow for more fine-grained control of route advertisement and policy enforcement.
BGP route reflection: BGP route reflection is a mechanism used to reduce the number of BGP sessions required in a network. Route reflectors receive routes from clients and advertise these routes to other routers, reducing the number of BGP sessions required in the network.
BGP confederations: BGP confederations are a mechanism used to divide a large autonomous system into smaller autonomous systems for the purposes of reducing the size of the AS and improving BGP convergence times.
In conclusion, BGP is a critical component of the Internet routing infrastructure and is essential for providing internet connectivity. Network engineers pursuing the CCNP certification should have a solid understanding of the key concepts and technologies of BGP, including BGP neighbors, attributes, best path selection, peering, communities, route reflection, and confederations.
BGP path selection process
- Prefer the path with the highest weight.
- Prefer the path with the highest local preference (LOCAL_PREF).
- Prefer the path that was originated by the local router (BGP LOCAL_ORIGIN).
- Prefer the path with the shortest AS_PATH.
- Prefer the path with the lowest origin type (IGP is lower than EGP, and EGP is lower than INCOMPLETE).
- Prefer the path with the lowest multi-exit discriminator (MED).
- Prefer eBGP over iBGP learned paths.
- Prefer the path with the lowest IGP metric to the next hop.
- Prefer the oldest path.
- If all paths have the same preference, a tie-break is done using the router-id.
- IBGP: To prevent loops in IBGP, the rule is that routers within the same AS must not advertise to each other prefixes learned from other IBGP routers within the same AS. This is done by enforcing the "next hop" attribute to remain unchanged when a prefix is passed between IBGP routers.
- EBGP: To prevent loops in EBGP, the rule is that routers will not advertise to a neighbor a prefix learned from another neighbor if the prefix has already been through that neighbor. This is done by comparing the "AS path" attribute of the prefix.
So in short, IBGP uses next-hop attribute and EBGP uses AS-path attribute to prevent routing loops.
What is BGP split horizon ?
Split horizon is a phenomenon in BGP that occurs when a router receives an update for a prefix from one of its neighbors, and then sends that update to another neighbor without changing the next hop attribute. This can cause a routing loop and is a problem in IBGP (Internal BGP) networks.
To avoid this we can do Full mesh , Route reflector , Confederation.
Route Reflectors: Route Reflectors are a feature of BGP that allows a router to act as a central hub for other routers within the same AS. This allows for a reduction in the number of IBGP sessions, which in turn reduces the risk of split horizon.
Confederation: A BGP Confederation is a method of breaking up a large AS into smaller autonomous systems, which are then connected by EBGP (External BGP) sessions. This allows for the use of IBGP within the smaller autonomous systems, reducing the risk of split horizon.
what is BGP next-hop-self ?
BGP next-hop-self is a command that is used on a BGP router to change the next hop attribute of a prefix when it is advertised to a neighbor. The command tells the router to advertise its own IP address as the next hop, rather than the IP address of the neighboring router. This is done to prevent routing loops that can occur when a prefix is passed between BGP routers within the same autonomous system (AS).
The next-hop-self command is typically used in IBGP (Internal BGP) networks, where routers within the same AS are not allowed to advertise prefixes learned from other IBGP routers within the same AS without changing the next hop. By advertising its own IP address as the next hop, the router ensures that updates are not sent back to the router from which they were received, which prevents loops from occurring.
BGP states
Idle: This is the initial state, where the BGP session is not established.
Connect: In this state, the BGP routers try to establish a TCP connection with each other.
OpenSent: In this state, the BGP router sends an Open message to its neighbor, which includes information such as the router's AS number, BGP version and other parameters.
OpenConfirm: In this state, the BGP router waits for the Open message to be acknowledged by its neighbor. If the message is acknowledged, the session moves to the Established state.
Established: In this state, the BGP session is fully established, and the routers can exchange routing updates. This is the normal operating state for a BGP session.
BGP (Border Gateway Protocol) uses four types of packets for communication between BGP routers:
- Open: sent to initiate a BGP session with another router.
- Update: sent to advertise or withdraw a route to or from another router.
- Notification: sent to indicate an error condition or to close a BGP session.
- Keepalive: sent to maintain the connection between BGP routers.
Several ways to inject routes into BGP:
- Use a network statement: This method involves manually configuring a BGP router to advertise a specific prefix by using the "network" command.
- Use an aggregate statement: This method allows to advertise a summarized prefix that covers multiple more specific prefixes.
- Redistribution: This method involves redistributing routes from another routing protocol, such as OSPF or static routes, into BGP.
- BGP peer-groups : this method allows to group multiple BGP peers and apply the same policies to them, so when the routes are received from one peer, it will be advertised to other peers in the group.
- default-information originate: This command is used on the router that is the best path to reach the default route. It tells the router to advertise a default route to its BGP peers, even if it doesn't have a default route in its routing table.
- Advertise a prefix-list: This method is used to filter prefixes before advertising to its BGP peer.
- Using route-map statement : This method is used to match prefixes and apply some actions like permit or deny the prefixes to be advertised to the BGP peers.
- What is BGP and what is it used for?
- BGP is a routing protocol used to exchange routing information between routers in different autonomous systems (AS) on the Internet.
- What is an Autonomous System in BGP?
- An Autonomous System (AS) is a collection of interconnected networks that are under a common administrative domain and share routing policies.
- What is a BGP route and how does BGP determine the best path?
- A BGP route is information about a network prefix and its path to reach that network. BGP determines the best path using various attributes such as AS_PATH, NEXT_HOP, and LOCAL_PREF.
- What is the difference between iBGP and eBGP?
- iBGP (Internal BGP) is a BGP configuration within a single AS, while eBGP (External BGP) is a BGP configuration between different ASs.
- What is BGP peering and how is it established?
- BGP peering is the process of establishing a BGP connection between two routers. It is established by configuring the routers with the necessary information such as IP address and AS number.
- What is the purpose of BGP communities?
- BGP communities are used to group together a set of prefixes and apply a specific routing policy to them.
- What is BGP route reflection and why is it used?
- BGP route reflection is a technique used to reduce the number of iBGP connections in a network by allowing one iBGP speaker to act as a route reflector for a group of iBGP speakers.
- What is BGP route filtering and how is it performed?
- BGP route filtering is the process of filtering or modifying incoming or outgoing BGP routes based on specific criteria. It is performed using access control lists (ACLs) or route maps.
- What is BGP convergence and how is it achieved?
- BGP convergence is the process of all routers in a network agreeing on the best path to a specific network. It is achieved through the exchange of routing information and the use of routing policies.
- What is BGP multipath and why is it used?
- BGP multipath is a feature that allows a BGP router to install multiple paths to the same destination in its routing table. It is used to provide load balancing and redundancy.
- How do you influence BGP routes?
- BGP routes can be influenced by setting the BGP attributes such as LOCAL_PREF, AS_PATH, MED, or communities.
- How does BGP calculate the best path?
- BGP calculates the best path based on a set of attributes, such as the length of the AS_PATH, the origin of the route, the next hop, the MED, and the local preference.
- What is the difference between a soft reset and a hard reset in BGP?
- A soft reset is a request to a BGP peer to renegotiate the BGP session without tearing down the current connection. A hard reset, on the other hand, terminates the current BGP session and establishes a new one.
- How does BGP handle route updates and route withdrawals?
- BGP handles route updates by sending an Update message to its BGP peers, which contains information about the new or modified route. Route withdrawals are handled by sending a Withdrawal message, indicating that a previously advertised route is no longer valid.
- How does BGP prevent routing loops?
- BGP prevents routing loops by using the AS_PATH attribute, which keeps track of the ASs that a route has passed through. If a BGP router receives a route with its own AS number in the AS_PATH, it discards the route to prevent a loop.
- What is BGP dampening and how does it work?
- BGP dampening is a mechanism that is used to reduce the impact of unstable or flapping routes in a BGP network. It works by suppressing or penalizing routes that flicker frequently, reducing the frequency of updates and thus stabilizing the network.
- What is the purpose of BGP communities and how are they used?
- BGP communities are used to group together a set of prefixes and apply a specific routing policy to them. They are used to allow fine-grained control over BGP routing policies, such as controlling the preferred path, influencing the MED, or controlling the propagation of specific routes.
- How does BGP handle route aggregation and route summarization?
- BGP handles route aggregation by grouping a set of more-specific routes into a single, less-specific aggregate route. This reduces the number of entries in the routing table and reduces the amount of routing information that needs to be exchanged between routers. Route summarization is a related technique that involves creating a summarized route for a group of contiguous network prefixes.