BGP Configuration on Cisco Nexus Switches

BGP Configuration on Cisco Nexus Switches

Welcome back, my faithful readers! In the last two blog posts, we delved into BGP in some depth. With that foundation, I believe we're ready to jump into configurations!

This blog will focus on BGP v4 configurations on Cisco Nexus switches.

Configuring BGP: The Three Major Steps

Configuring BGP involves three main steps:

  1. Enabling the BGP feature.
  2. Starting the BGP process associated with an Autonomous System (AS).
  3. Configuring BGP peers.

We'll use a simple setup to demonstrate these configurations. Imagine two N7K Nexus switches within the same organization (and thus the same AS) connected to an ISP's router, which acts as the gateway to the internet.

N7K Configuration within the AS

An N7K switch in the AS will have the following configuration:

1. Enable BGP

feature bgp

2. Start the BGP Process

router bgp 123222
  router-id 10.10.10.10
  address-family ipv4 unicast
  • router-id: Assigns a router ID to the BGP process.
  • address-family: Specifies the address family for the BGP process (e.g., unicast/multicast, IPv4, or IPv6).

3. Configure BGP Peers

Within the BGP process, you'll need to configure both internal and external neighbor peers:

router bgp 123222
  neighbor 45.233.21.23 remote-as 50401
    description "Connection to ISP1"
    address-family ipv4 unicast
  neighbor 192.168.76.89 remote-as 123222
    description "Internal peer N7K"
    update-source Loopback0
    address-family ipv4 unicast
    next-hop-self
  neighbor 192.168.76.89 default-local-preference 150
  • description: Adds a description for administrative purposes.
  • update-source: Specifies the source of BGP updates and sessions.
  • next-hop-self: Forces the router to use its own IP address as the next-hop for internal routes. This is crucial when iBGP peers are not directly connected.
  • default-local-preference: Sets the local preference for routes learned from this neighbor.

Route-maps

Route-maps provide granular control over BGP attributes for specific routes. They're used when you want to manipulate metrics for certain routes, rather than all routes from a neighbor.

To use a route-map, you first create an Access Control List (ACL) or prefix-list to match the desired routes. Then, you create a route-map that uses the ACL or prefix-list. Finally, you apply the route-map to the neighbor.

ip prefix-list MY_PREFIX_LIST permit 192.168.1.0/24

route-map set_local_pref permit 10
  match ip prefix-list MY_PREFIX_LIST
  set local-preference 200

router bgp 123222
  neighbor 192.168.76.89 route-map set_local_pref in

In this example, the match ip prefix-list MY_PREFIX_LIST line in the route-map ties the route-map to the defined prefix-list. Routes matching the prefix-list will have their local preference set to 200.

Peer Groups

Peer groups simplify configuration when you have multiple neighbors with similar settings. You configure the settings on the peer group, and they apply to all members. This significantly reduces configuration redundancy and makes management easier. This is especially useful in larger networks with many BGP neighbors.

router bgp <your_as>
  bgp peer-group <peer_group_name>
    neighbor <neighbor1_ip> peer-group <peer_group_name>
    neighbor <neighbor2_ip> peer-group <peer_group_name>
    bgp peer-group <peer_group_name> default-local-preference <value>

! Example:
router bgp 65001
  bgp peer-group IBGP_PEERS
    neighbor 192.168.1.1 peer-group IBGP_PEERS
    neighbor 192.168.1.2 peer-group IBGP_PEERS
    neighbor 192.168.1.3 peer-group IBGP_PEERS
    bgp peer-group IBGP_PEERS default-local-preference 120

  route-map SET_LOCAL_PREF permit 10
    match ip prefix-list MY_PREFIX_LIST
    set local-preference 150

  bgp peer-group IBGP_PEERS route-map SET_LOCAL_PREF in
  bgp peer-group IBGP_PEERS route-map PREPEND_AS out
  bgp peer-group IBGP_PEERS update-source Loopback0

Peer groups are particularly useful for iBGP configurations where many routers share similar policies.

MP-BGP Configuration on Cisco Nexus

Cisco Nexus switches support Multiprotocol Border Gateway Protocol (MP-BGP), which allows a single BGP process to handle multiple address families. This enables the simultaneous routing of, for example, IPv4 unicast and IPv6 unicast addresses.

Here's a basic configuration example demonstrating MP-BGP on a Cisco Nexus switch:

router bgp 65001
  router-id 1.1.1.1
  address-family ipv4 unicast
    neighbor 2.2.2.2 remote-as 65002
    exit-address-family
  address-family ipv6 unicast
    neighbor 2.2.2.2 activate
    exit-address-family
  interface Loopback0
    ipv6 address 2001::1/128

Conclusion

This blog post covered the fundamentals of configuring BGP on Cisco Nexus switches. This included enabling BGP, starting the BGP process, configuring BGP peers, using route-maps for granular control, leveraging peer groups for simplified management, and configuring MP-BGP for IPv4 and IPv6 routing. Remember to always test your BGP configurations in a lab environment before implementing them in production. For further learning, consult the official Cisco Nexus documentation.