router bgp [asn]
Enters BGP router configuration mode for the specified autonomous system number.
Overview
The 'router bgp [asn]' command is the fundamental entry point for configuring the Border Gateway Protocol (BGP) on Cisco Nexus switches running NX-OS. BGP is the de facto exterior gateway protocol used to exchange routing information between autonomous systems (ASes) on the Internet and within large enterprise networks. On NX-OS, this command places the device into BGP router configuration mode, where all BGP-specific parameters—such as neighbor definitions, address-family configurations, route policies, and timers—are defined. The autonomous system number (ASN) specified must be unique to the administrative domain; it can be a public ASN (1-64511) for Internet-facing BGP or a private ASN (64512-65535) for internal use. Before issuing this command, the BGP feature must be enabled globally using 'feature bgp'. On Nexus platforms, BGP configuration is hierarchical: after entering 'router bgp [asn]', you typically configure neighbor relationships and then enter address-family configuration mode (e.g., 'address-family ipv4 unicast') to activate BGP for specific address families. This command is used in both data center and campus networks to establish BGP peering, implement route reflectors, or enable multipath. In troubleshooting workflows, verifying that the correct ASN is configured is a first step when BGP sessions fail to establish. The command itself does not produce output; instead, it changes the CLI context. Verification is done using 'show running-config | section router bgp' to review the configuration or 'show ip bgp summary' to check session status.
router bgp {asn}When to Use This Command
- Configuring BGP peering with an ISP in a data center environment.
- Setting up iBGP within a campus network for route propagation.
- Enabling BGP multipath load balancing across multiple links.
- Configuring route reflectors to scale iBGP in a large enterprise.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| asn | <1-65535> | The autonomous system number of the local BGP router. Must be a 16-bit number between 1 and 65535. Public ASNs (1-64511) are used for Internet peering; private ASNs (64512-65535) are for internal use. On NX-OS, 4-byte ASNs are also supported using the 'asn [4-byte]' format, but the basic command uses a 16-bit value. |
Command Examples
Basic BGP Router Configuration
router bgp 65001switch(config)# router bgp 65001 switch(config-router)#
Enters BGP configuration mode for AS 65001. The prompt changes to config-router, indicating BGP subcommands are available.
Entering BGP with a Private ASN
router bgp 64512switch(config)# router bgp 64512 switch(config-router)#
Enters BGP configuration mode for private AS 64512, commonly used in internal networks.
Understanding the Output
The command itself does not produce output beyond changing the prompt. The prompt changes from 'switch(config)#' to 'switch(config-router)#', indicating that subsequent commands will be applied to the BGP process. This is the entry point for all BGP configuration. No show output is generated; verification is done with 'show running-config | section router bgp' or 'show ip bgp summary'.
Configuration Scenarios
Basic eBGP Peering with ISP
A Nexus switch in a data center connects to an ISP router for Internet access. The local AS is 65001, ISP AS is 65000.
Topology
[Nexus]---[ISP Router]
AS 65001 AS 65000Steps
- 1.Enable BGP feature: 'feature bgp'
- 2.Enter BGP configuration: 'router bgp 65001'
- 3.Configure neighbor: 'neighbor 10.0.0.1 remote-as 65000'
- 4.Activate IPv4 unicast: 'address-family ipv4 unicast' and 'neighbor 10.0.0.1 activate'
! Config snippet
feature bgp
router bgp 65001
neighbor 10.0.0.1 remote-as 65000
address-family ipv4 unicast
neighbor 10.0.0.1 activateVerify: Use 'show ip bgp summary' to verify the session state is 'Established'.
Watch out: Ensure the ISP router has a matching neighbor statement pointing back to the Nexus's IP and ASN.
iBGP with Route Reflector
A route reflector (RR) in AS 65001 peers with multiple client routers to scale iBGP.
Topology
[RR]---[Client1]
|---[Client2]
AS 65001Steps
- 1.Enable BGP: 'feature bgp'
- 2.Configure RR: 'router bgp 65001'
- 3.Define neighbor and set route-reflector-client: 'neighbor 192.168.1.1 remote-as 65001' and 'neighbor 192.168.1.1 route-reflector-client'
- 4.Activate address-family: 'address-family ipv4 unicast' and 'neighbor 192.168.1.1 activate'
! Config snippet
feature bgp
router bgp 65001
neighbor 192.168.1.1 remote-as 65001
neighbor 192.168.1.1 route-reflector-client
address-family ipv4 unicast
neighbor 192.168.1.1 activateVerify: Check 'show ip bgp neighbors 192.168.1.1' to see 'Route-Reflector-Client: True'.
Watch out: Clients must not be fully meshed; they only peer with the RR.
Troubleshooting with This Command
When troubleshooting BGP on NX-OS, the first step is to verify that the BGP feature is enabled using 'show feature | include bgp'. If BGP is not listed, enable it with 'feature bgp'. Next, confirm the router bgp configuration is correct by examining 'show running-config | section router bgp'. Common issues include mismatched AS numbers, incorrect neighbor IP addresses, or missing address-family activation. Use 'show ip bgp summary' to quickly view the state of all BGP peers. An 'Idle' state often indicates a problem with the TCP connection or a misconfiguration. 'Active' means the router is trying to connect, while 'Established' is the desired state. If a session is not establishing, check connectivity with 'ping' to the neighbor IP and verify that TCP port 179 is not blocked by ACLs. On NX-OS, BGP sessions can also be affected by the 'update-source' interface configuration; ensure the correct source IP is used. For route advertisement issues, use 'show ip bgp neighbors [neighbor] advertised-routes' and 'show ip bgp neighbors [neighbor] routes' to see what is being sent and received. Additionally, 'show ip bgp' displays the BGP table. If routes are missing, check prefix-list or route-map filters applied to the neighbor. NX-OS also supports 'debug ip bgp updates' for real-time troubleshooting, but use with caution in production. Finally, verify that the BGP process is not in a 'shutdown' state under the neighbor configuration.
CCNA Exam Tips
Remember that the ASN must match the one configured on peers for eBGP sessions.
On NX-OS, BGP configuration is done under 'router bgp' and not under 'router bgp' with address-family immediately; address-family is a subcommand.
Be aware that NX-OS requires the 'feature bgp' command to be enabled before entering 'router bgp'.
Common Mistakes
Forgetting to enable 'feature bgp' first, resulting in '% Invalid command' error.
Using an ASN that conflicts with the neighbor's ASN for eBGP, causing session not to establish.
Not specifying the correct VRF context when BGP is used in multiple VRFs.
Platform Notes
On Cisco NX-OS, the 'router bgp' command behaves similarly to Cisco IOS but with some key differences. First, NX-OS requires the 'feature bgp' command to be enabled globally before 'router bgp' is accepted; IOS does not have a feature-based enablement for BGP. Second, NX-OS uses a hierarchical configuration model where address-family configurations are submodes under the BGP router, whereas IOS often uses 'address-family ipv4' directly under the BGP process. Third, NX-OS supports virtual routing and forwarding (VRF) contexts; BGP can be configured per VRF using 'vrf [name]' under 'router bgp'. In IOS, VRF-aware BGP is configured differently. Fourth, NX-OS has a 'maximum-paths' command under the address-family, while IOS uses 'maximum-paths' under the BGP router. Additionally, NX-OS supports 4-byte ASNs with the 'asn' command in the format 'asn 1.2', but the basic 'router bgp' command expects a 16-bit ASN. For equivalent commands on other platforms, on Juniper JunOS, the equivalent is 'set protocols bgp group [group-name]' with 'local-as [asn]'. On Arista EOS, it is 'router bgp [asn]' similar to NX-OS. Version differences: NX-OS versions prior to 5.0 had different BGP configuration syntax; always consult the documentation for your specific NX-OS release.
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions