Featured Posts

Networking

Networking

CCIE-Journals

CCIE-Journals
From Student to Engineer,a journey of discovery.

BGP

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:

  1. Autonomous System (AS): An AS is a collection of interconnected IP routing prefixes under the control of a single administrative entity.

  2. BGP neighbors: BGP neighbors are routers that have established a BGP session and are exchanging routing information.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.


when there are two router paths going to internet, we want to use one path over other Using BGP. how to configure it ?

To configure BGP to use one path over another to the internet, We can set a higher local preference value on the desired path for outbound. This tells BGP to prefer the path with the higher local preference value when determining the best path to a destination.

For inbound, we use AS path prepend.
When a router advertises a prefix to its BGP neighbors, it can add its own AS number multiple times to the AS path attribute of the prefix. This makes the path appear longer to other routers.


So for outbound we use Local preference , For inbound we use AS path prepend.

Other ways to influence Outbound:

Weight , Communities

Other ways to influence Inbound:

MED, Communities.



Configuration of Local preference
========================
router bgp "local-as-number" neighbor "IP address" remote-as "number" neighbor "IP address" local-preference "value"

Configuration of As-path prepend
==========================

router bgp "local-as-number" neighbor "IP address" remote-as "number" neighbor "IP address" aspath-prepend "local-as" "local-as" "local-as"



How BGP prevents Loops ? IBGP and EBGP


  • 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.

  1. 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.

  2. 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

  1. Idle: This is the initial state, where the BGP session is not established.

  2. Connect: In this state, the BGP routers try to establish a TCP connection with each other.

  3. 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.

  4. 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.

  5. 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 packet Types

BGP (Border Gateway Protocol) uses four types of packets for communication between BGP routers:

  1. Open: sent to initiate a BGP session with another router.
  2. Update: sent to advertise or withdraw a route to or from another router.
  3. Notification: sent to indicate an error condition or to close a BGP session.
  4. Keepalive: sent to maintain the connection between BGP routers.

Several ways to inject routes into BGP:

  1. Use a network statement: This method involves manually configuring a BGP router to advertise a specific prefix by using the "network" command.
  2. Use an aggregate statement: This method allows to advertise a summarized prefix that covers multiple more specific prefixes.
  3. Redistribution: This method involves redistributing routes from another routing protocol, such as OSPF or static routes, into BGP.
  4. 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.
  5. 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.
  6. Advertise a prefix-list: This method is used to filter prefixes before advertising to its BGP peer.
  7. 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.


Top interview questions on bgp

  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.


More Advanced
============
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.