router bgp [asn]
Enters BGP configuration mode for a specified autonomous system number on Cisco IOS-XR.
Overview
The 'router bgp <asn>' command is the entry point for configuring the Border Gateway Protocol (BGP) on Cisco IOS-XR devices. BGP is the de facto exterior gateway protocol used to exchange routing information between autonomous systems (ASes) on the Internet. This command initiates the BGP process for a specific AS number, allowing the network administrator to define BGP neighbors, advertise networks, apply route policies, and tune BGP parameters. In IOS-XR, BGP configuration is hierarchical: after entering the BGP configuration mode, you can configure global BGP parameters, define neighbor relationships, and then enter address-family submodes to specify which address families (IPv4, IPv6, VPNv4, etc.) are exchanged. IOS-XR also supports multiple BGP instances using the 'instance' keyword, enabling separate BGP processes for different purposes (e.g., one for internet peering, another for MPLS VPN). This command is typically the first step in any BGP configuration workflow. Understanding its syntax and behavior is crucial for network engineers working with service provider or large enterprise networks. The command does not produce any operational output; instead, it changes the configuration context. Verification of BGP operation is done using show commands like 'show bgp summary' or 'show bgp neighbors'. The 'router bgp' command is available in global configuration mode and requires appropriate privileges.
router bgp <asn>When to Use This Command
- Configuring BGP peering with an ISP for internet connectivity.
- Setting up BGP route reflectors in a large enterprise network.
- Implementing BGP multipath load balancing across multiple links.
- Configuring BGP communities to influence routing policies.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| asn | <1-65535> | The autonomous system number (ASN) that identifies the BGP process. Must be a valid 16-bit or 32-bit AS number. In IOS-XR, 4-byte AS numbers are supported using the 'asplain' format (e.g., 65536). |
| instance | instance <instance-name> | Optional keyword to create or enter a named BGP instance. This allows multiple BGP processes within the same router, each with its own configuration and neighbors. The instance name is a string. |
Command Examples
Enter BGP configuration for AS 65000
router bgp 65000RP/0/RP0/CPU0:router(config)# router bgp 65000 RP/0/RP0/CPU0:router(config-bgp)#
The command enters BGP configuration mode for autonomous system 65000. The prompt changes to (config-bgp)# indicating BGP sub-mode.
Enter BGP configuration for AS 100 with a named instance
router bgp 100 instance ISP1RP/0/RP0/CPU0:router(config)# router bgp 100 instance ISP1 RP/0/RP0/CPU0:router(config-bgp-instance)#
This enters BGP configuration for AS 100 with a named instance 'ISP1'. The prompt changes to (config-bgp-instance)#, allowing configuration specific to that instance.
Understanding the Output
The command itself does not produce output beyond changing the prompt. The prompt indicates the current configuration mode. In Cisco IOS-XR, after entering 'router bgp <asn>', the prompt changes to 'router(config-bgp)#' for the default BGP process. If a named instance is specified, the prompt becomes 'router(config-bgp-instance)#'. This indicates that subsequent commands will configure BGP parameters such as neighbor relationships, address families, and route policies. The absence of error messages means the AS number is valid and the command was accepted. If the AS number is invalid (e.g., out of range 1-65535), an error message is displayed. The prompt is the key indicator that you are in the correct mode to configure BGP.
Configuration Scenarios
Basic BGP Peering with an ISP
A company with AS 65000 wants to peer with an ISP (AS 100) for internet connectivity.
Topology
[Company Router] -- eBGP -- [ISP Router]Steps
- 1.Enter global configuration mode.
- 2.Enter BGP configuration for AS 65000: 'router bgp 65000'.
- 3.Configure the neighbor: 'neighbor 192.0.2.1 remote-as 100'.
- 4.Advertise the company's network: 'network 203.0.113.0/24'.
- 5.Exit BGP configuration.
! router bgp 65000 neighbor 192.0.2.1 remote-as 100 ! address-family ipv4 unicast network 203.0.113.0/24 ! !
Verify: Use 'show bgp summary' to verify the BGP session is established. Use 'show bgp neighbors 192.0.2.1' for detailed status.
Watch out: Ensure the neighbor's IP address is reachable via an IGP or static route before BGP peering. Also, the network statement must match a route in the routing table exactly.
Multiple BGP Instances for MPLS VPN
A service provider uses separate BGP instances for internet peering and MPLS VPN services.
Topology
[PE Router] -- iBGP (VPNv4) -- [Route Reflector]Steps
- 1.Enter global configuration mode.
- 2.Create BGP instance for internet: 'router bgp 100 instance INTERNET'.
- 3.Configure internet peering.
- 4.Create BGP instance for VPN: 'router bgp 100 instance VPN'.
- 5.Configure VPNv4 address family and route reflector clients.
! router bgp 100 instance INTERNET neighbor 198.51.100.1 remote-as 200 address-family ipv4 unicast network 192.0.2.0/24 ! ! router bgp 100 instance VPN bgp router-id 10.0.0.1 neighbor 10.0.0.2 remote-as 100 address-family vpnv4 unicast route-reflector-client ! !
Verify: Use 'show bgp instance INTERNET summary' and 'show bgp instance VPN summary' to verify each instance.
Watch out: Each BGP instance operates independently; they do not share routes unless explicitly configured. Ensure route policies are correctly applied to prevent route leaks.
Troubleshooting with This Command
When troubleshooting BGP issues on Cisco IOS-XR, the 'router bgp' command itself is not used for troubleshooting; it is a configuration command. However, verifying that the BGP process is correctly configured is the first step. Common issues include: incorrect AS number, missing neighbor configuration, or address family not activated. Use 'show running-config router bgp' to review the current BGP configuration. If the BGP process is not starting, check that the AS number is valid and that the router has sufficient memory. For peering issues, use 'show bgp summary' to see if the session is up. If the session is down, 'show bgp neighbors <ip>' provides detailed error messages. In IOS-XR, BGP configuration is modular; ensure that the neighbor is configured under the correct address family. For example, if you configure a neighbor under 'router bgp 100' but forget to activate it under 'address-family ipv4 unicast', the session will not establish. Also, check that route policies are correctly applied and that the 'send-community' attribute is set if communities are used. Use 'debug bgp' commands cautiously in production. For route advertisement issues, verify that the 'network' statement matches a route in the routing table and that the route is not suppressed by a route policy. In multi-instance scenarios, ensure that the correct instance is being configured. The 'show bgp instance all' command lists all instances. If BGP routes are not being installed in the routing table, check the maximum-paths configuration and the administrative distance. IOS-XR also supports BGP graceful restart and NSR; verify these features if session flaps are observed.
CCNA Exam Tips
Remember that in IOS-XR, BGP configuration is done under 'router bgp <asn>' and not under 'router bgp <asn> router-id' like in IOS.
Be aware that IOS-XR supports multiple BGP instances using the 'instance' keyword, which is not available in classic IOS.
Know that the AS number must match the one configured under the BGP process; otherwise, peering will fail.
Common Mistakes
Forgetting to specify the AS number; the command 'router bgp' without an ASN will be rejected.
Using the wrong AS number, which can cause BGP peering to fail or create routing loops.
Confusing IOS-XR syntax with IOS; in IOS-XR, you must use 'router bgp <asn>' and then configure address families separately.
Platform Notes
Cisco IOS-XR differs significantly from classic IOS in BGP configuration. In IOS-XR, the 'router bgp' command does not include the router-id; instead, the router-id is configured separately under the BGP process or globally. IOS-XR uses a hierarchical configuration model: after entering 'router bgp <asn>', you must enter address-family submodes to configure network advertisements and neighbor activation. In classic IOS, you can configure 'network' and 'neighbor' directly under the BGP process without explicit address-family submodes for IPv4 unicast. IOS-XR also supports multiple BGP instances using the 'instance' keyword, which is not available in classic IOS. This allows separate BGP processes for different address families or purposes. In IOS-XR, the 'bgp' command is used for global BGP parameters like 'bgp router-id', 'bgp log-neighbor-changes', etc. The 'neighbor' command syntax is similar but requires explicit 'remote-as' under the neighbor configuration. For route policies, IOS-XR uses route-policy language (RPL) instead of route-maps. Additionally, IOS-XR supports 4-byte AS numbers natively. Equivalent commands on other platforms: Juniper JunOS uses 'set protocols bgp group <group-name>', and Arista EOS uses 'router bgp <asn>' similar to IOS. In IOS-XR, the 'show bgp' commands provide detailed output with fields like 'Status codes' and 'Origin codes'. Version differences: In IOS-XR 6.0 and later, the default BGP behavior includes address-family IPv4 unicast activation for all neighbors unless explicitly disabled. Earlier versions required explicit activation.
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions