BGPBGP Config

neighbor [ip]

Configures a BGP neighbor and enters neighbor configuration mode on Cisco IOS-XR.

Overview

The 'neighbor' command in Cisco IOS-XR BGP configuration is fundamental for establishing BGP peering sessions. It allows the network engineer to specify a BGP neighbor by IP address or peer-group and enter a sub-configuration mode where all parameters for that neighbor are defined. This command is used in both eBGP (External BGP) and iBGP (Internal BGP) scenarios. In IOS-XR, BGP configuration is hierarchical: after entering 'router bgp <asn>', the 'neighbor' command creates a neighbor context. Within this context, you set the remote AS, update source, timers, address-family capabilities, and route policies. Unlike Cisco IOS, IOS-XR requires explicit address-family configuration under the neighbor to exchange routes. The command is essential for building scalable BGP networks, especially in service provider environments where multiple neighbors with different policies are common. It fits into troubleshooting workflows by allowing verification of neighbor parameters via 'show running-config' or 'show bgp neighbors'. Misconfigurations often lead to peering not establishing or routes not being exchanged.

Syntax·BGP Config
neighbor {ip-address | ipv6-address | peer-group-name}

When to Use This Command

  • Establish BGP peering with a directly connected router in an ISP network.
  • Configure eBGP multihop peering across a routed network.
  • Set up iBGP peering between routers in the same autonomous system.
  • Apply BGP policies to a specific neighbor for route filtering.

Parameters

ParameterSyntaxDescription
ip-addressA.B.C.DIPv4 address of the BGP neighbor. Must be reachable and match the neighbor's interface or loopback.
ipv6-addressX:X:X:X::XIPv6 address of the BGP neighbor. Used for IPv6 BGP peering.
peer-group-nameWORDName of a peer-group template. Using a peer-group simplifies configuration by applying common settings to multiple neighbors.

Command Examples

Basic eBGP Neighbor Configuration

neighbor 192.0.2.2
router bgp 65000
 neighbor 192.0.2.2
  remote-as 65001
  address-family ipv4 unicast
   route-policy PASS-ALL in
   route-policy PASS-ALL out
  !
 !

Enters neighbor configuration mode for 192.0.2.2. The remote-as sets the neighbor's AS. Address-family sub-mode configures policies for IPv4 unicast routes.

iBGP Neighbor with Update-Source

neighbor 10.0.0.1
router bgp 65000
 neighbor 10.0.0.1
  remote-as 65000
  update-source Loopback0
  address-family ipv4 unicast
   next-hop-self
  !
 !

Configures iBGP neighbor using loopback interface as source. next-hop-self ensures the router advertises itself as next-hop for routes learned from this neighbor.

Understanding the Output

The output shows the BGP configuration hierarchy. The 'neighbor' command enters a sub-configuration mode where parameters like remote-as, update-source, and address-family policies are set. Each line under the neighbor defines a specific attribute. For example, 'remote-as' specifies the neighbor's autonomous system number. 'address-family ipv4 unicast' enters the address-family sub-mode where inbound and outbound route policies are applied. Healthy configuration shows consistent remote-as and appropriate policies. Missing remote-as or address-family blocks indicate incomplete configuration. In show commands, the neighbor state should be 'Established' for active sessions; otherwise, check timers or connectivity.

Configuration Scenarios

eBGP Peering with Directly Connected Neighbor

Two routers in different ASes connected via a point-to-point link.

Topology

R1 (AS 65000) --- 192.0.2.0/30 --- R2 (AS 65001)

Steps

  1. 1.Enter BGP configuration on R1: router bgp 65000
  2. 2.Add neighbor: neighbor 192.0.2.2
  3. 3.Set remote AS: remote-as 65001
  4. 4.Configure address-family: address-family ipv4 unicast
  5. 5.Apply route policies: route-policy PASS-ALL in/out
Configuration
!
router bgp 65000
 neighbor 192.0.2.2
  remote-as 65001
  address-family ipv4 unicast
   route-policy PASS-ALL in
   route-policy PASS-ALL out
  !
 !
!

Verify: Use 'show bgp neighbors 192.0.2.2' to check state is 'Established'.

Watch out: Ensure the interface IP is correct and that no ACL blocks TCP port 179.

iBGP Peering with Loopback Update-Source

Two routers in same AS using loopback interfaces for stability.

Topology

R1 (Loopback0: 10.0.0.1) --- R2 (Loopback0: 10.0.0.2)

Steps

  1. 1.Enter BGP config on R1: router bgp 65000
  2. 2.Add neighbor: neighbor 10.0.0.2
  3. 3.Set remote AS: remote-as 65000
  4. 4.Set update-source: update-source Loopback0
  5. 5.Configure address-family: address-family ipv4 unicast
  6. 6.Optionally set next-hop-self
Configuration
!
router bgp 65000
 neighbor 10.0.0.2
  remote-as 65000
  update-source Loopback0
  address-family ipv4 unicast
   next-hop-self
  !
 !
!

Verify: Check 'show bgp neighbors 10.0.0.2' and ensure the BGP session uses the loopback IP.

Watch out: Both routers must have reachability to each other's loopback via IGP.

Troubleshooting with This Command

When a BGP session fails to establish, the 'neighbor' command configuration is the first place to check. Use 'show running-config router bgp' to verify the neighbor's remote-as, update-source, and address-family settings. Common issues include missing remote-as, incorrect update-source (e.g., using a physical interface that goes down), or mismatched address-family capabilities. In IOS-XR, the 'show bgp neighbors <ip>' command provides detailed state information. If the state is 'Idle', check that the neighbor IP is reachable via ping. If 'Active', the router is trying to connect; ensure no firewall blocks TCP 179. If 'OpenSent' or 'OpenConfirm', there may be an AS number mismatch or authentication issue. The 'debug bgp' commands can be used but with caution in production. Also, verify that the neighbor's BGP configuration is consistent (e.g., same hold time, MD5 password if configured). For iBGP, ensure the update-source is a loopback and that IGP routes exist. For eBGP, check that the TTL is sufficient (default 1 for directly connected, use 'ebgp-multihop' for non-direct).

CCNA Exam Tips

1.

Remember that in IOS-XR, the neighbor command enters a sub-configuration mode; you must exit back to BGP config to add another neighbor.

2.

For eBGP, the remote-as must be different from the local AS; for iBGP, it must be the same.

3.

Use 'update-source' for iBGP peering over loopback to ensure stability.

Common Mistakes

Forgetting to specify remote-as, causing the neighbor to be rejected.

Not entering address-family configuration, so no routes are exchanged.

Using the wrong IP address (e.g., using a non-loopback interface for iBGP without update-source).

Platform Notes

In Cisco IOS-XR, the BGP configuration model is significantly different from classic Cisco IOS. The 'neighbor' command creates a sub-mode where all parameters are set, rather than using separate commands like 'neighbor <ip> remote-as <as>' in one line. IOS-XR requires explicit address-family configuration under the neighbor to activate route exchange; without it, no routes are advertised or received. This is a common pitfall for engineers migrating from IOS. Additionally, IOS-XR uses route-policies instead of route-maps for filtering. The 'neighbor' command also supports peer-groups, which are templates that can be applied to multiple neighbors, reducing configuration overhead. In terms of version differences, IOS-XR 6.0 and later have enhanced support for BGP-LU and BGP FlowSpec. For equivalent commands on other platforms, Juniper uses 'set protocols bgp group <name> neighbor <ip>' and Arista uses 'neighbor <ip> remote-as <as>' in a similar hierarchical structure.

Practice for the CCNA 200-301

Test your knowledge with hundreds of CCNA practice questions covering all exam domains.

Practice CCNA Questions