BORDER GATEWAY PROTOCOL BGP

Overview of BGP

  • Features
    • Exchange routing information between different Autonomous Systems (ASes).
    • Scalable for large networks.
    • Supports policy-based routing decisions.
    • Provides redundancy and fault tolerance.
  • Functions
    • Establish and maintain peering relationships.
    • Exchange routing information using TCP connections.
    • Select the best path based on attributes.
    • Advertise and withdraw routes as network conditions change.
  • Versions
    • BGPv4 is the most commonly used version.
    • Previous versions include BGP-1, BGP-2, and BGP-3.
    • Each version introduces enhancements and improvements in functionality and scalability.

Autonomous System Numbers (ASNs)

  • Autonomous System (AS): A collection of IP networks and routers under a single organization’s control that presents a common routing policy to the internet.
  • Autonomous System Number (ASN): A unique identifier assigned to each AS.
  • Public ASNs:
    • Globally unique.
    • Assigned by regional internet registries (RIRs).
    • Required for ASes interacting over the internet.
  • Private ASNs:
    • Used for private networks.
    • Range: 64512 to 65534.

 ASN Format

  • 16-bit ASN Range: 0 to 65535.
  • 32-bit ASN Range: 0 to 4294967295.
  • 32-bit ASN Representation:
    • Single decimal number (e.g., 4200000000).
    • Dot notation (e.g., 65536.1).

ASN Allocation

  • Managed by the Internet Assigned Numbers Authority (IANA).
  • Distributed by regional internet registries (RIRs).
  • Organizations apply to RIRs for public ASNs.

BGP and ASNs

  • Path Vector Protocol: BGP uses ASNs to track the path of routing information.
  • Loop Prevention: BGP examines the AS path to avoid routing loops.

BGP Path Attributes

BGP Path Attributes are key components used by BGP to determine the best path to a destination. They provide information about the routes and influence the route selection process.

Types of Path Attributes

  • Well-Known Mandatory
    • Attributes that must be recognized and included in every BGP update.
    • Examples: AS_PATH, NEXT_HOP, ORIGIN.
  • Well-Known Discretionary
    • Attributes that must be recognized but are not required in every BGP update.
    • Example: LOCAL_PREF.
  • Optional Transitive
    • Attributes that may not be recognized by all BGP implementations but should be passed along to other BGP peers.
    • Examples: AGGREGATOR, COMMUNITY.
  • Optional Non-Transitive
    • Attributes that may not be recognized and should not be passed along to other BGP peers.
    • Example: MED (Multi-Exit Discriminator).

Address Families

  • Enable BGP to handle different types of network protocols (e.g., IPv4, IPv6) and their routes within a single BGP instance
    • IPv4 Unicast: Standard IPv4 routing.
    • IPv6 Unicast: IPv6 routing.
    • IPv4 Multicast: IPv4 multicast routing.
    • IPv6 Multicast: IPv6 multicast routing.
    • VPNv4 and VPNv6: MPLS VPN routing for IPv4 and IPv6

Inter-Router Communication

  • BGP Neighbor Discovery:
    • Unlike IGP protocols (e.g., OSPF) that use hello packets to discover neighbors dynamically, BGP requires manual configuration of neighbors using their IP addresses.
    • BGP does not use hello packets, which means that two BGP neighbors cannot discover each other dynamically.
  • TCP Communication:
    • BGP uses TCP port 179 for communication between routers.
    • TCP provides reliable delivery, ensuring that BGP messages are transmitted accurately.
    • BGP relies on TCP features such as fragmentation, sequencing, acknowledgment, and retransmission.
  • Single-Hop vs Multi-Hop:
    • BGP can form neighbor adjacencies that are directly connected (single-hop) or multiple hops away (multi-hop).
    • For single-hop BGP sessions, neighbors are directly connected and can locate each other using the ARP table.
    • For multi-hop BGP sessions, routing table information (static routes or IGP) is required to find the peer’s IP address.

BGP Session Types

BGP sessions are categorized into two main types: Internal BGP (iBGP) and External BGP (eBGP). Each type serves a different purpose and has unique characteristics.

  • Internal BGP (iBGP)
    • Definition: iBGP sessions are established between routers within the same Autonomous System (AS).
    • Administrative Distance: iBGP routes have an administrative distance of 200.
    • Use Cases: Typically used within an AS to ensure all routers have a consistent view of external routes. It’s essential for implementing complex routing policies and providing transit connectivity within an AS.
    • iBGP Considerations:
      • Full Mesh Requirement: All iBGP routers must be connected in a full mesh.
      • Scalability Solutions: Route Reflectors or Confederations.
  • External BGP (eBGP)
    • Definition: eBGP sessions are established between routers in different Autonomous Systems.
    • Administrative Distance: eBGP routes have an administrative distance of 20.
    • Use Cases: Used for exchanging routing information between different ASes. It forms the backbone of internet routing.
    • eBGP Considerations:
      • TTL and Multi-Hop: Default TTL of 1, ebgp-multihop command for multi-hop sessions.
      • AS Path Attribute: Ensures loop prevention.

BGP Messages

BGP (Border Gateway Protocol) uses four main types of messages to establish and maintain routing information between peers. Each message serves a specific function in the BGP process.

  • OPEN Message : Establishes a BGP adjacency and negotiates session capabilities. Contents are:
    • BGP version number
    • Autonomous System Number (ASN) of the originating router
    • Hold time (the proposed value for the hold timer in seconds)
    • BGP identifier (router ID)
    • Optional parameters for session capabilities
    • Example: When Router A wants to form a BGP session with Router B, it sends an OPEN message including its ASN, hold time, and router ID. Router B responds with its own OPEN message, and they negotiate the session parameters.
  • UPDATE Message : Advertises new routes, updates existing routes, or withdraws previously advertised routes. Contents are:
    • Withdrawn Routes: Lists prefixes that should no longer be considered valid.
    • Network Layer Reachability Information (NLRI): Contains the prefixes being advertised.
    • Path Attributes: Various attributes associated with the routes (e.g., AS_PATH, NEXT_HOP).

Example: If Router A learns about a new route to a network from Router B, it sends an UPDATE message to Router C, advertising the new route with the necessary path attributes.

  • NOTIFICATION Message: Indicates an error condition and closes the BGP session. Contents are:
    • Error code and subcode (to specify the type of error)
    • Data related to the error (if applicable)
    • Example: If Router A detects a configuration error or receives an invalid update from Router B, it sends a NOTIFICATION message to Router B indicating the error type and then closes the session.
  • KEEPALIVE Message: Ensures that the BGP session is still active and the neighbor is reachable. Contents are:
    • Minimal content – mainly acts as a heartbeat to keep the session alive.
    • Example: Routers exchange KEEPALIVE messages at regular intervals (usually one-third of the hold time) to confirm that the connection is still alive. If Router A doesn’t receive a KEEPALIVE from Router B within the hold time, it will consider the session down.

BGP Neighbor States

  • Idle
    • Initial State: BGP is waiting to start a connection.
    • Actions: Initialize resources, start TCP connection.
    • Transitions: Move to Connect if successful, remain in Idle if there are issues.
  • Connect
    • TCP Connection: Waiting for the TCP connection to complete.
    • Actions: Send OPEN message upon successful TCP connection.
    • Transitions: Move to OpenSent if successful, Active if connection fails.
  • Active
    • Connection Attempt: Actively trying to establish TCP connection.
    • Actions: Retry TCP connection, send OPEN message if successful.
    • Transitions: Remain in Active if fails, move to OpenSent if successful.
  • OpenSent
    • Awaiting Response: Sent OPEN message, waiting for neighbor’s OPEN message.
    • Actions: Verify received parameters, send KEEPALIVE if valid.
    • Transitions: Move to OpenConfirm if parameters are acceptable, Idle if error.
  • OpenConfirm
    • Confirmation: Sent KEEPALIVE, waiting for neighbor’s KEEPALIVE.
    • Actions: Await KEEPALIVE from neighbor to confirm connection.
    • Transitions: Move to Established if KEEPALIVE received, Idle if error.
  • Established
    • Full Session: BGP session is established, exchanging routing information.
    • Actions: Exchange UPDATE, KEEPALIVE, NOTIFICATION messages.

Basic BGP Configuration

  • Initialize BGP:

router bgp <as-number>

  • Define Router ID (Optional):

bgp router-id <router-id>

  • Identify Neighbors:

neighbor <ip-address> remote-as <as-number>

  • Initialize Address Family:

address-family <afi> <safi>

  • Activate Neighbor Address Family:

neighbor <ip-address> activate

  • Verification Commands:
    • Show BGP Summary:

show ip bgp summary

  • Show BGP Neighbors:

show ip bgp neighbors

  • Example Configuration:
    • R1 (AS 65100):

router bgp 65100

 bgp router-id 192.168.1.1

 neighbor 10.12.1.2 remote-as 65200

 address-family ipv4

neighbor 10.12.1.2 activate

  • network 192.168.1.0 mask 255.255.255.0
    • R2 (AS 65200):

router bgp 65200

 bgp router-id 192.168.2.2

 neighbor 10.12.1.1 remote-as 65100

 address-family ipv4

neighbor 10.12.1.1 activate

 network 192.168.2.0 mask 255.255.255.0

Route Advertisement

Route advertisement is a crucial aspect of BGP, enabling routers to share information about networks they can reach. In BGP, routes are advertised using the network command under the BGP configuration. Here’s how you can understand and configure route advertisement in BGP.

  • BGP Network Command:
    • Advertises a specific network.
    • Network must exist in the IP routing table.
  • Criteria for Advertisement:
    • Network must be present in the IP routing table via static or dynamic routing.
  • BGP Synchronization:
    • Historically required routes to be in IGP before advertising.
    • Often disabled in modern networks.
  • Configuration Steps:
    • Advertise a Network:

network <network> mask <subnet-mask>

  • Ensure Network in Routing Table:

Add route: ip route <network> <subnet-mask> <next-hop-ip>

  • Example Configuration:
    • Router R1 (AS 65100):

router bgp 65100

 bgp router-id 192.168.1.1

 neighbor 10.12.1.2 remote-as 65200

address-family ipv4

 neighbor 10.12.1.2 activate

network 192.168.1.0 mask 255.255.255.0

ip route 192.168.1.0 255.255.255.0 null0

  • Router R2 (AS 65200):

router bgp 65200

 bgp router-id 192.168.2.2

 neighbor 10.12.1.1 remote-as 65100

 address-family ipv4

  neighbor 10.12.1.1 activate

  network 192.168.2.0 mask 255.255.255.0

 ip route 192.168.2.0 255.255.255.0 null0

IPv4 Route Summarization

Route summarization, also known as route aggregation, reduces the number of routes that routers need to process. This technique combines multiple IP routes into a single route with a shorter prefix, which can then be advertised in routing updates.

  • Benefits
    • Reduced Routing Table Size: Fewer routes to manage.
    • Improved Convergence: Faster routing updates.
    • Less Memory Usage: Reduced resource consumption on routers.
    • Increased Stability: Minimizes the impact of route flapping.

Aggregate Address in BGP

The aggregate-address command in BGP is used to create a summarized route from multiple specific routes. This summarized route can help reduce the size of the routing table and enhance routing efficiency.

  • Benefits
    • Reduced Routing Table Size: Fewer routes to manage, which leads to reduced memory usage and faster lookups.
    • Improved Convergence: Aggregated routes can help in reducing the convergence time of the routing protocol.
    • Simplified Network Management: Aggregation makes the network design simpler and easier to manage.
  • Command Syntax

aggregate-address <network> <mask> [summary-only] [as-set] [attribute-map <map-name>]

  • Options
    • summary-only: Advertises only the summary route.

aggregate-address 192.168.16.0 255.255.252.0 summary-only

  • as-set: Includes AS_PATH information of summarized routes.

aggregate-address 192.168.16.0 255.255.252.0 as-set

  • attribute-map: Applies additional attributes to the aggregate route using a route map.

route-map SET-METRIC permit 10

set metric 100

router bgp 65100

aggregate-address 192.168.16.0 255.255.252.0 attribute-map SET-METRIC

Multiprotocol BGP for IPv6

Multiprotocol BGP (MP-BGP) is an extension of BGP that allows BGP to carry routing information for multiple network layer protocols. This includes support for IPv6, which is essential for modern networks transitioning from IPv4.

  • Address Family Identifier (AFI):
    • Identifies the type of network protocol (e.g., IPv4 or IPv6).
    • For IPv6, AFI is 2.
  • Subsequent Address Family Identifier (SAFI):
    • Provides additional information about the type of addresses carried.
    • For IPv6 unicast, SAFI is 1.
  • BGP Capabilities Negotiation:
    • During the BGP session establishment, peers negotiate capabilities, including support for MP-BGP.
  • Example Configuration

router bgp 65100

bgp router-id 1.1.1.1

no bgp default ipv4-unicast

neighbor 2001:db8::2 remote-as 65200

address-family ipv6

neighbor 2001:db8::2 activate

network 2001:db8:1::/64

IPv6 Route Summarization

Route summarization for IPv6 in BGP works similarly to IPv4. It combines multiple IPv6 routes into a single summary route, reducing the size of the routing table and improving efficiency.

  • router bgp 65100

address-family ipv6

aggregate-address 2001:db8:0::/62 summary-only

  • Verification
    • Show BGP IPv6 Summary:
      • Use the show bgp ipv6 unicast summary command to display the status of IPv6 BGP sessions.
    • Show BGP IPv6 Routes:
      • Use the show bgp ipv6 unicast command to display the IPv6 BGP routing table.
    • Show IPv6 Route:
      • Use the show ipv6 route command to verify the presence of the summary route in the IP routing table.

Review Questions

Q: What does MP-BGP stand for?

A: Multiprotocol Border Gateway Protocol.

Q: What is the Address Family Identifier (AFI) for IPv6?

A: 2

Q: What is the Subsequent Address Family Identifier (SAFI) for IPv6 unicast?

A: 1

Q: Why is MP-BGP important?

A: It allows BGP to carry routing information for multiple network layer protocols, including IPv6.

Q: What command initializes the BGP process for AS 65100?

A: router bgp 65100

Q: How do you disable the default IPv4 unicast address family in BGP?

A: no bgp default ipv4-unicast

Q: How do you define a BGP neighbor with IP 2001:db8::2 in remote AS 65200?

A: neighbor 2001:db8::2 remote-as 65200

Q: How do you activate the IPv6 address family for the neighbor 2001:db8::2?

A: address-family ipv6, then neighbor 2001:db8::2 activate

Q: How do you advertise the IPv6 network 2001:db8:1::/64 in BGP?

A: network 2001:db8:1::/64

Q: What must be true for an IPv6 network to be advertised by BGP?

A: The network must be present in the router’s IPv6 routing table.

Q: What is route summarization?

A: Combining multiple IP routes into a single summary route to reduce routing table size and improve efficiency.

Q: How do you configure a summary route for the networks 2001:db8:0:1::/64, 2001:db8:0:2::/64, 2001:db8:0:3::/64, and 2001:db8:0:4::/64 into 2001:db8:0::/62?

A: aggregate-address 2001:db8:0::/62 summary-only

Q: Which command displays the status of IPv6 BGP sessions?

A: show bgp ipv6 unicast summary

Q: Which command displays the IPv6 BGP routing table?

A: show bgp ipv6 unicast

Q: Which command verifies the presence of the summary route in the IPv6 routing table?

A: show ipv6 route

Q: What is route flapping?

A: Frequent up-and-down state changes of a route in a network.

Q: What are common causes of route flapping?

A: Unstable links, faulty hardware, software bugs, misconfigurations, environmental factors.

Q: How can route flapping be mitigated in BGP?

A: Using route dampening and improving network stability.

Q: What is the purpose of the aggregate-address command in BGP?

A: To create a summarized route from multiple specific routes.

Q: What does the summary-only option do in the aggregate-address command?

A: Advertises only the summary route and suppresses the more specific routes.

Q: What does the as-set option do in the aggregate-address command?

A: Includes the AS_PATH information of the summarized routes to help in loop prevention.

Q: How do you apply additional attributes to an aggregate route using a route map?

A: Use the attribute-map option with the aggregate-address command.

Leave a Comment

Your email address will not be published. Required fields are marked *