neighbor [ip]
Configures a BGP neighbor and enters neighbor configuration mode on Cisco IOS-XR.
Definition: neighbor [ip] is a Cisco IOS-XR bgp config command. 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.
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
| Parameter | Syntax | Description |
|---|---|---|
| ip-address | A.B.C.D | IPv4 address of the BGP neighbor. Must be reachable and match the neighbor's interface or loopback. |
| ipv6-address | X:X:X:X::X | IPv6 address of the BGP neighbor. Used for IPv6 BGP peering. |
| peer-group-name | WORD | Name 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.2router 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.1router 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.Enter BGP configuration on R1: router bgp 65000
- 2.Add neighbor: neighbor 192.0.2.2
- 3.Set remote AS: remote-as 65001
- 4.Configure address-family: address-family ipv4 unicast
- 5.Apply route policies: route-policy PASS-ALL in/out
! 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.Enter BGP config on R1: router bgp 65000
- 2.Add neighbor: neighbor 10.0.0.2
- 3.Set remote AS: remote-as 65000
- 4.Set update-source: update-source Loopback0
- 5.Configure address-family: address-family ipv4 unicast
- 6.Optionally set next-hop-self
! 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
Remember that in IOS-XR, the neighbor command enters a sub-configuration mode; you must exit back to BGP config to add another neighbor.
For eBGP, the remote-as must be different from the local AS; for iBGP, it must be the same.
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).
neighbor [ip] vs address-family ipv4 unicast
The commands 'neighbor [ip]' and 'address-family ipv4 unicast' are commonly confused because both are used in BGP neighbor configuration, but they operate at different levels: one defines the neighbor itself, while the other activates a specific address family under that neighbor, allowing route exchange.
| Aspect | neighbor [ip] | address-family ipv4 unicast |
|---|---|---|
| Scope | Defines the BGP neighbor and enters neighbor sub-mode | Activates IPv4 unicast address family under a specific neighbor |
| Configuration mode | Entered from BGP config mode (router bgp) | Entered from BGP neighbor config mode |
| Persistence | Persists after exiting neighbor mode; neighbor is configured | Persists only if the neighbor configuration exists; otherwise removed |
| Precedence | Must be configured before any address-family commands | Requires the neighbor to be already defined |
| Typical use | Establishing a BGP peering session with a remote router | Enabling exchange of IPv4 unicast NLRIs over the BGP session |
| Effect | Creates a BGP neighbor entry; no routes exchanged until address-family activated | Enables the neighbor to send and receive IPv4 unicast routes |
Use neighbor [ip] when you need to define a new BGP neighbor or enter its configuration context.
Use address-family ipv4 unicast when you need to activate IPv4 unicast route exchange under an existing BGP neighbor.
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 CCNP Service Provider
Test your knowledge with practice questions covering all CCNP Service Provider exam domains.
Practice CCNP Service Provider Questions