Configuring Basic BGP

This chapter describes how to configure Border Gateway Protocol (BGP) on the Cisco NX-OS device.

This chapter includes the following sections:

About Basic BGP

Cisco NX-OS supports BGP version 4, which includes multiprotocol extensions that allow BGP to carry routing information for IP multicast routes and multiple Layer 3 protocol address families. BGP uses TCP as a reliable transport protocol to create TCP sessions with other BGP-enabled devices.

BGP uses a path-vector routing algorithm to exchange routing information between BGP-enabled networking devices or BGP speakers. Based on this information, each BGP speaker determines a path to reach a particular destination while detecting and avoiding paths with routing loops. The routing information includes the actual route prefix for a destination, the path of autonomous systems to the destination, and other path attributes.

BGP selects a single path, by default, as the best path to a destination host or network. Each path carries well-known mandatory, well-known discretionary, and optional transitive attributes that are used in BGP best-path analysis. You can influence BGP path selection by altering some of these attributes by configuring BGP policies. See the Route Policies and Resetting BGP Sessions section for more information.

BGP also supports load balancing. See the BGP Best-Path Selection section for more information.


Note

Cisco Nexus 3550-T hardware does not supports installing ECMP routes.


BGP Autonomous Systems

An autonomous system (AS) is a network controlled by a single administration entity. An autonomous system forms a routing domain with one or more interior gateway protocols (IGPs) and a consistent set of routing policies. BGP supports 16-bit and 32-bit autonomous system numbers.

Separate BGP autonomous systems dynamically exchange routing information through external BGP (eBGP) peering sessions. BGP speakers within the same autonomous system can exchange routing information through internal BGP (iBGP) peering sessions.

4-Byte AS Number Support

BGP supports 2-byte autonomous system (AS) numbers in plain-text notation or as.dot notation and 4-byte AS numbers in plain-text notation.

Administrative Distance

An administrative distance is a rating of the trustworthiness of a routing information source. By default, BGP uses the administrative distances shown in the table.

Table 1. BGP Default Administrative Distances

Distance

Default Value

Function

External

20

Applied to routes learned from eBGP.

Internal

200

Applied to routes learned from iBGP.

Local

220

Applied to routes originated by the router.


Note

The administrative distance does not influence the BGP path selection algorithm, but it does influence whether BGP-learned routes are installed in the IP routing table.


BGP Peers

A BGP speaker does not discover another BGP speaker automatically. You must configure the relationships between BGP speakers. A BGP peer is a BGP speaker that has an active TCP connection to another BGP speaker.

BGP Sessions

BGP uses TCP port 179 to create a TCP session with a peer. When a TCP connection is established between peers, each BGP peer initially exchanges all of its routes—the complete BGP routing table—with the other peer. After this initial exchange, the BGP peers send only incremental updates when a topology change occurs in the network or when a routing policy change occurs. In the periods of inactivity between these updates, peers exchange special messages called keepalives. The hold time is the maximum time limit that can elapse between receiving consecutive BGP update or keepalive messages.

Cisco NX-OS supports the following peer configuration options:

  • Individual IPv4 address—BGP establishes a session with the BGP speaker that matches the remote address and AS number.

  • IPv4 prefix peers for a single AS number—BGP establishes sessions with BGP speakers that match the prefix and the AS number.

  • Dynamic AS number prefix peers—BGP establishes sessions with BGP speakers that match the prefix and an AS number from a list of configured AS numbers.

Dynamic AS Numbers for Prefix Peers and Interface Peers

Cisco NX-OS accepts a range or list of AS numbers to establish BGP sessions. For example, if you configure BGP to use IPv4 prefix 192.0.2.0/8 and AS numbers 33, 66, and 99, BGP establishes a session with 192.0.2.1 with AS number 66 but rejects a session from 192.0.2.2 with AS number 50.

Cisco NX-OS does not associate prefix peers with dynamic AS numbers as either interior BGP (iBGP) or external BGP (eBGP) sessions until after the session is established. See the "Configuring Advanced BGP" chapter for more information on iBGP and eBGP.


Note

The dynamic AS number prefix peer configuration overrides the individual AS number configuration that is inherited from a BGP template. For more information, see the "Configuring Advanced BGP" chapter.


BGP Router Identifier

To establish BGP sessions between peers, BGP must have a router ID, which is sent to BGP peers in the OPEN message when a BGP session is established. The BGP router ID is a 32-bit value that is often represented by an IPv4 address. You can configure the router ID. By default, Cisco NX-OS sets the router ID to the IPv4 address of a loopback interface on the router. If no loopback interface is configured on the router, the software chooses the highest IPv4 address configured to a physical interface on the router to represent the BGP router ID. The BGP router ID must be unique to the BGP peers in a network.

If BGP does not have a router ID, it cannot establish any peering sessions with BGP peers.

BGP and the Unicast RIB

BGP communicates with the unicast routing information base (unicast RIB) to store IPv4 routes in the unicast routing table. After selecting the best path, if BGP determines that the best path change needs to be reflected in the routing table, it sends a route update to the unicast RIB.

BGP receives route notifications regarding changes to its routes in the unicast RIB. It also receives route notifications about other protocol routes to support redistribution.

BGP also receives notifications from the unicast RIB regarding next-hop changes. BGP uses these notifications to keep track of the reachability and IGP metric to the next-hop addresses.

Whenever the next-hop reachability or IGP metrics in the unicast RIB change, BGP triggers a best-path recalculation for affected routes.

Prerequisites for BGP

BGP has the following prerequisites:

  • You must enable BGP (see the Enabling BGP section).

  • You should have a valid router ID configured on the system.

  • You must have an AS number, either assigned by a Regional Internet Registry (RIR) or locally administered.

  • You must configure at least one IGP that is capable of recursive next-hop resolution.

  • You must configure an address family under a neighbor for the BGP session establishment.

Guidelines and Limitations for Basic BGP

BGP has the following configuration guidelines and limitations:

  • With sufficient scale (such as - hundreds of peers and thousands of routes per peer) the Graceful Restart mechanism may fail because the default 5 minute stale-path timer might not be enough for BGP convergence to complete before the timer expires. Use the following command to verify the actual time taken for the convergence process:

    switch# show bgp vrf all all neighbors | in First|RIB
      Last End-of-RIB received 0.022810 after session start
      Last End-of-RIB sent 00:08:36 after session start
      First convergence 00:08:36 after session start with 398002 routes sent
    

    Note

    In Cisco Nexus 3550-T BGP is supported only in default VRF.


  • The dynamic AS number prefix peer configuration overrides the individual AS number configuration that is inherited from a BGP template.

  • If you configure a dynamic AS number for prefix peers in an AS confederation, BGP establishes sessions with only the AS numbers in the local confederation.

  • BGP sessions that are created through a dynamic AS number prefix peer ignore any configured eBGP multihop time-to-live (TTL) value or a disabled check for directly connected peers.

  • Configure a router ID for BGP to avoid automatic router ID changes and session flaps.

  • Use the maximum-prefix configuration option per peer to restrict the number of routes that are received and system resources used.

  • Configure the update source to establish a session with BGP/eBGP multihop sessions.

  • Specify a BGP policy if you configure redistribution.

  • If you decrease the keepalive and hold timer values, you might experience BGP session flaps.

  • Although the show ip bgp commands are available for verifying the BGP configuration, Cisco recommends that you use the show bgp commands instead.

  • BGP prefix independent convergence (PIC) edge feature is not supported in Cisco Nexus 3550-T.

Default Settings

Table 2. Default BGP Parameters

Parameters

Default

BGP feature

Disabled

Keep alive interval

60 seconds

Hold timer

180 seconds

Auto-summary

Always disabled

Synchronization

Always disabled

CLI Configuration Modes

The following sections describe how to enter each of the CLI configuration modes for BGP. From a mode, you can enter the ? command to display the commands available in that mode.

Global Configuration Mode

Use global configuration mode to create a BGP process and configure advanced features such as AS confederation and route dampening.

This example shows how to enter router configuration mode:

switch# configuration 
switch(config)# router bgp 64496
switch(config-router)# 

Neighbor Configuration Mode

Cisco NX-OS provides the neighbor configuration mode to configure BGP peers. You can use neighbor configuration mode to configure all parameters for a peer.

The following example shows how to enter neighbor configuration mode:

switch(config)# router bgp 64496
switch(config-router)# neighbor 192.0.2.1
switch(config-router-neighbor)# 

Configuring Basic BGP

To configure a basic BGP, you must enable BGP and configure a BGP peer. Configuring a basic BGP network consists of a few required tasks and many optional tasks. You must configure a BGP routing process and BGP peers.


Note

If you are familiar with the Cisco IOS CLI, be aware that the Cisco NX-OS commands for this feature might differ from the Cisco IOS commands that you would use.


Enabling BGP

You must enable BGP before you can configure BGP.

Procedure

  Command or Action Purpose
Step 1

configure terminal

Example:

switch# configure terminal
switch(config)#

Enters configuration mode.

Step 2

[no] feature bgp

Example:

switch(config)# feature bgp

Enables BGP.

Use the no form of this command to disable this feature.

Step 3

(Optional) show feature

Example:

switch(config)# show feature 
(Optional)

Displays enabled and disabled features.

Step 4

(Optional) copy running-config startup-config

Example:

switch(config)# copy running-config
startup-config
(Optional)

Saves this configuration change.

Creating a BGP Instance

You can create a BGP instance and assign a router ID to the BGP instance. For more information, see the BGP Router Identifier section.

Before you begin

  • You must enable BGP (see the Enabling BGP section).

  • BGP must be able to obtain a router ID (for example, a configured loopback address).

Procedure

  Command or Action Purpose
Step 1

configure terminal

Example:

switch# configure terminal
switch(config)#

Enters configuration mode.

Step 2

[no] router bgp autonomous-system-number

Example:

switch(config)# router bgp 64496
switch(config-router)#

Enables BGP and assigns the AS number to the local BGP speaker. The AS number can be a 16-bit integer or a 32-bit integer in the form of a higher 16-bit decimal number and a lower 16-bit decimal number in xx.xx format.

Use the no option with this command to remove the BGP process and the associated configuration.

Step 3

(Optional) router-id ip-address

Example:

switch(config-router)# router-id
192.0.2.255
(Optional)

Configures the BGP router ID. This IP address identifies this BGP speaker.

Step 4

(Optional) address-family {ipv4} {unicast}

Example:

switch(config-router)# address-family
ipv4 unicast
switch(config-router-af)#
(Optional)

Enters global address family configuration mode for the IPv4 address family.

Note 

In Cisco Nexus 3550-T BGP supports only IPv4 Unicast address family.

Step 5

(Optional) network {ip-address/length | ip-address mask mask} [route-map map-name]

Example:

switch(config-router-af)# network 10.10.10.0/24

Example:

switch(config-router-af)# network 10.10.10.0 mask 255.255.255.0
(Optional)

Specifies a network as local to this autonomous system and adds it to the BGP routing table.

For exterior protocols, the network command controls which networks are advertised. Interior protocols use the network command to determine where to send updates.

Step 6

(Optional) show bgp all

Example:

switch(config-router-af)# show bgp all
(Optional)

Displays information about all BGP address families.

Step 7

(Optional) copy running-config startup-config

Example:

switch(config-router-af)# copy running-config
startup-config
(Optional)

Saves this configuration change.

Example

This example shows how to enable BGP with the IPv4 unicast address family and manually add one network to advertise:

switch# configure terminal
switch(config)# router bgp 64496
switch(config-router)# address-family ipv4 unicast
switch(config-router-af)# network 192.0.2.0
switch(config-router-af)# copy running-config startup-config

Restarting a BGP Instance

You can restart a BGP instance and clear all peer sessions for the instance.

To restart a BGP instance and remove all associated peers, use the following command:

Procedure

Command or Action Purpose

restart bgpinstance-tag

Example:

switch(config)# restart bgp 201

Restarts the BGP instance and resets or reestablishes all peering sessions.

Shutting Down BGP

You can shut down the BGP protocol and gracefully disable BGP while retaining the configuration.

To shut down BGP, use the following command in router configuration mode:

Procedure

Command or Action Purpose

shutdown

Example:

switch(config-router)# shutdown

Restarts the BGP instance and resets or reestablishes all peering sessions.

Configuring BGP Peers

You can configure a BGP peer within a BGP process. Each BGP peer has an associated keepalive timer and hold timers. You can set these timers either globally or for each BGP peer. A peer configuration overrides a global configuration.


Note

You must configure the address family under neighbor configuration mode for each peer.


Before you begin

Procedure

  Command or Action Purpose
Step 1

configure terminal

Example:

switch# configure terminal
switch(config)#

Enters configuration mode.

Step 2

router bgp autonomous-system-number

Example:

switch(config)# router bgp 64496
switch(config-router)# 

Enables BGP and assigns the AS number to the local BGP speaker. The AS number can be a 16-bit integer or a 32-bit integer in the form of a higher 16-bit decimal number and a lower 16-bit decimal number in xx.xx format.

Step 3

neighbor {ip-address} remote-as as-number

Example:

switch(config-router)# neighbor
209.165.201.1 remote-as 64497
switch(config-router-neighbor)# 

Configures the IPv4 address and AS number for a remote BGP peer. The ip-address format is x.x.x.x. The format is A:B::C:D.

Step 4

neighbor-as as-number

Example:

switch(config-router-neighbor)# remote-as 64497

Configures the AS number for a remote BGP peer.

Step 5

(Optional) descriptiontext

Example:

switch(config-router-neighbor)#
description Peer Router B
switch(config-router-neighbor)# 
(Optional)

Adds a description for the neighbor. The description is an alphanumeric string up to 80 characters.

Step 6

(Optional) timerskeepalive-time hold-time

Example:

switch(config-router-neighbor)# timers
30 90
(Optional)

Adds the keepalive and hold time BGP timer values for the neighbor. The range is from 0 to 3600 seconds. The default is 60 seconds for the keepalive time and 180 seconds for the hold time.

Step 7

(Optional) shutdown

Example:

switch(config-router-neighbor)# shutdown
(Optional)

Administratively shuts down this BGP neighbor. This command triggers an automatic notification and session reset for the BGP neighbor sessions.

Step 8

address-family{ipv4} {unicast}

Example:

switch(config-router-neighbor)#
address-family ipv4 unicast
switch(config-router-neighbor-af)#

Enters neighbor address family configuration mode for the unicast IPv4 address family.

Step 9

(Optional) weight value

Example:

switch(config-router-neighbor-af)#
weight 100
(Optional)

Sets the default weight for routes from this neighbor. The range is from 0 to 65535.

All routes learned from this neighbor have the assigned weight initially. The route with the highest weight is chosen as the preferred route when multiple routes are available to a particular network. The weights assigned with the set weight route-map command override the weights assigned with this command.

If you specify a BGP peer policy template, all the members of the template inherit the characteristics configured with this command.

Step 10

(Optional) show bgp {ipv4} {unicast} neighbors

Example:

switch(config-router-neighbor-af)# show
bgp ipv4 unicast neighbors
(Optional)

Displays information about BGP peers.

Step 11

(Optional) copy running-config startup-config

Example:

switch(config-router-neighbor-af)# copy
running-config startup-config
(Optional)

Saves this configuration change.

Example

The following example shows how to configure a BGP peer:

switch# configure terminal
switch(config)# router bgp 64496
switch(config-router)# neighbor 192.0.2.1 remote-as 64497
switch(config-router-neighbor)# description Peer Router B
switch(config-router-neighbor)# address-family ipv4 unicast
switch(config-router-neighbor)# weight 100
switch(config-router-neighbor-af)# copy running-config startup-config

Configuring Dynamic AS Numbers for Prefix Peers

You can configure multiple BGP peers within a BGP process. You can limit BGP session establishment to a single AS number or multiple AS numbers in a route map.

BGP sessions configured through dynamic AS numbers for prefix peers ignore the ebgp-multihop command and the disable-connected-check command.

You can change the list of AS numbers in the route map, but you must use the no neighbor command to change the route-map name. Changes to the AS numbers in the configured route map affect only new sessions.

Before you begin

  • You must enable BGP (see the Enabling BGP section).

Procedure

  Command or Action Purpose
Step 1

configure terminal

Example:

switch# configure terminal
switch(config)#

Enters configuration mode.

Step 2

router bgp autonomous-system-number

Example:

switch(config)# router bgp 64496
switch(config-router)#

Enables BGP and assigns the AS number to the local BGP speaker. The AS number can be a 16-bit integer or a 32-bit integer in the form of a higher 16-bit decimal number and a lower 16-bit decimal number in xx.xx format.

Step 3

neighbor prefix remote-as route-map map-name

Example:

switch(config-router)# neighbor
192.0.2.0/8 remote-as routemap BGPPeers
switch(config-router-neighbor)#

Configures the IPv4 prefix and a route map for the list of accepted AS numbers for the remote BGP peers. The prefix format for IPv4 is x.x.x.x/length. The length range is from 1 to 32.

The map-name can be any case-sensitive, alphanumeric string up to 63 characters.

Step 4

neighbor-as as-number

Example:

switch(config-router-neighbor)# remote-as 64497

Configures the AS number for a remote BGP peer.

Step 5

(Optional) show bgp {ipv4 {unicast } neighbors

Example:

switch(config-router-neighbor-af)# show
bgp ipv4 unicast neighbors
(Optional)

Displays information about BGP peers.

Step 6

(Optional) copy running-config startup-config

Example:

switch(config-router-neighbor-af)# copy
running-config startup-config
(Optional)

Saves this configuration change.

Example

This example shows how to configure dynamic AS numbers for a prefix peer:

switch# configure terminal
switch(config)# route-map BGPPeers
switch(config-route-map)# match as-number 64496, 64501-64510
switch(config-route-map)# match as-number as-path-list List1, List2
switch(config-route-map)# exit
switch(config)# router bgp 64496
switch(config-router)# neighbor 192.0.2.0/8 remote-as route-map BGPPeers
switch(config-router-neighbor)# description Peer Router B
switch(config-router-neighbor)# address-family ipv4 unicast
switch(config-router-neighbor-af)# copy running-config startup-config

Clearing BGP Information

To clear BGP information, use the following commands:

Command Purpose

clear bgp all {neighbor | * | as-number | peer-template name | prefix}

Clears one or more neighbors from all address families. * clears all neighbors in all address families. The arguments are as follows:

  • neighbor —IPv4 address of a neighbor.

  • as-number — Autonomous system number. The AS number can be a 16-bit integer or a 32-bit integer in the form of higher 16-bit decimal number and a lower 16-bit decimal number in xx.xx format.

  • name —Peer template name. The name can be any case-sensitive, alphanumeric string up to 64 characters.

  • prefix —IPv4 prefix. All neighbors within that prefix are cleared.

clear bgp all dampening

Clears route flap dampening networks in all address families.

clear bgp all flap-statistics

Clears route flap statistics in all address families.

clear bgp {ipv4 } {unicast} dampening

Clears route flap dampening networks in the selected address family.

clear bgp {ipv4 } {unicast} flap-statistics

Clears route flap statistics in the selected address family.

clear bgp {ipv4 } {neighbor |* | as-number | peer-template name | prefix}

Clears one or more neighbors from the selected address family. * clears all neighbors in the address family. The arguments are as follows:

  • neighbor —IPv4 address of a neighbor.

  • as-number — Autonomous system number. The AS number can be a 16-bit integer or a 32-bit integer in the form of higher 16-bit decimal number and a lower 16-bit decimal number in xx.xx format.

  • name —Peer template name. The name can be any case-sensitive, alphanumeric string up to 64 characters.

  • prefix —IPv4 prefix. All neighbors within that prefix are cleared.

clear bgp {ip {unicast}} {neighbor |* |as-number | peer-template name | prefix}

Clears one or more neighbors. * clears all neighbors in the address family. The arguments are as follows:

  • neighbor —IPv4 address of a neighbor.

  • as-number — Autonomous system number. The AS number can be a 16-bit integer or a 32-bit integer in the form of higher 16-bit decimal number and a lower 16-bit decimal number in xx.xx format.

  • name —Peer template name. The name can be any case-sensitive, alphanumeric string up to 64 characters.

  • prefix —IPv4 prefix. All neighbors within that prefix are cleared.

clear bgp dampening [ip-neighbor | ip-prefix]

Clears route flap dampening in one or more networks. The arguments are as follows:

  • ip-neighbor —IPv4 address of a neighbor.

  • ip-prefix —IPv4. All neighbors within that prefix are cleared.

clear bgp flap-statistics [ip-neighbor | ip-prefix]

Clears route flap statistics in one or more networks. The arguments are as follows:

  • ip-neighbor —IPv4 address of a neighbor.

  • ip-prefix —IPv4. All neighbors within that prefix are cleared.

Verifying the Basic BGP Configuration

To display the BGP configuration, perform one of the following tasks:

Command Purpose

show bgp all [summary]

Displays the BGP information for all address families.

show bgp convergence

Displays the BGP information for all address families.

show bgp {ipv4 } {unicast} [ip-address community [regexp expression | [community] [no-advertise] [no-export] [no-export-subconfed]}

Displays the BGP routes that match a BGP community.

show bgp {ipv4 } {unicast} [ip-address ] community-list list-name

Displays the BGP routes that match a BGP community list.

show bgp {ipv4 } {unicast} [ip-address | extcommunity [regexp expression | [generic [non-transitive | transitive] aa4:nn [exact-match]}

Displays the BGP routes that match a BGP extended community.

show bgp {ipv4 } {unicast} [ip-address | extcommunity-list list-name [exact-match]}

Displays the BGP routes that match a BGP extended community list.

show bgp {ipv4 } {unicast} [ip-address | {dampening dampened-paths [regexp expression]}

Displays the information for BGP route dampening. Use the clear bgp dampening command to clear the route flap dampening information.

show bgp {ipv4 } {unicast} [ip-address | history-paths [regexp expression]

Displays the BGP route history paths.

show bgp {ipv4 } {unicast} [ip-address | filter-list list-name

Displays the information for the BGP filter list.

show bgp {ipv4 } {unicast} [ip-address] neighbors [ip-address ]

Displays the information for BGP peers. Use the clear bgp neighbors command to clear these neighbors.

show bgp {ipv4 } {unicast} [ip-address ] neighbors [ip-address ] {nexthop | nexthop-database}

Displays the information for the BGP route next hop.

show bgp paths

Displays the BGP path information.

show bgp {ipv4 } {unicast} [ip-address ] policy name

Displays the BGP policy information. Use the clear bgp polic y command to clear the policy information.

show bgp {ipv4 } {unicast} [ip-address] prefix-list list-name

Displays the BGP routes that match the prefix list.

show bgp {ipv4} {unicast} [ip-address] received-paths

Displays the BGP paths stored for soft reconfiguration.

show bgp {ipv4} {unicast} [ip-address] regexp expression

Displays the BGP routes that match the AS_path regular expression.

show bgp {ipv4} {unicast} [ip-address] route-map map-name

Displays the BGP routes that match the route map.

show bgp peer-policy name

Displays the information about BGP peer policies.

show bgp peer-session name

show bgp peer-session

Displays the information about BGP peer sessions.

show bgp peer-template name

Displays the information about BGP peer templates. Use the clear bgp peer-template command to clear all neighbors in a peer template.

show bgp process

Displays the BGP process information.

show {ipv4} bgp [options]

Displays the BGP status and configuration information.

show {ipv4} mbgp [options]

Displays the BGP status and configuration information.

show running-configuration bgp

Displays the current running BGP configuration.

Monitoring BGP Statistics

To display BGP statistics, use the following commands:

Command

Purpose

show bgp {ipv4 } {unicast} [ip-address] flap-statistics

Displays the BGP route flap statistics. Use the clear bgp flap-statistics command to clear these statistics.

show bgp sessions

Displays the BGP sessions for all peers. Use the clear bgp sessions command to clear these statistics.

show bgp statistics

Displays the BGP statistics.

Configuration Examples for Basic BGP

This example shows a basic BGP configuration:

switch(config)# feature bgp
switch(config)# router bgp 64496
switch(config-router)# neighbor 10.10.10.10 remote-as 64496
switch(config-router-af)# next-hop-self

Where to Go Next

See Configuring Advanced BGP, for details on the following features:

  • Peer templates

  • Route redistribution

  • Route maps