Settle a problem:41
This document addresses a common BGP routing challenge involving next-hop reachability in an eBGP multihop environment, as detailed in the Cisco Community discussion. The scenario involves three routers (R1, R2, and R3) where R1 and R3 are eBGP peers over their loopback interfaces, and R2 acts as a transit router. A critical aspect of the topology is the segmentation of the Interior Gateway Protocol (IGP); R1 and R2 share an IGP domain (e.g., OSPF Area 0), while R2 and R3 share a separate IGP domain.
Topology Overview:
ebgp-multihop
is configured on both R1 and R3 to allow the peering.The Problem: R3 advertises its local prefix (e.g., 3.3.3.3/32 from Loopback0) to R1 via eBGP. R1 receives the BGP update, but because the BGP next-hop attribute is set to R3’s Loopback0 IP address—an address unknown to R1’s IGP—the route is considered inaccessible. Consequently, R1 does not install the prefix into its Routing Information Base (RIB) or Forwarding Information Base (FIB), rendering it unusable for traffic forwarding. This can be verified on R1 with show ip bgp <prefix>
, where the route will be present in the BGP table but will not be marked as valid and best (*>
).
The core challenge is to make the BGP next-hop reachable without resorting to static routes or redistributing BGP routes into the IGP, which are generally considered poor network design practices.
Understanding the default BGP next-hop behavior is crucial to solving this issue.
NEXT_HOP
attribute to the IP address of the interface used to reach that peer.update-source
: When peering between loopbacks, the update-source loopbackX
command is used. This causes the router to source its BGP packets from the loopback interface. A side effect is that, by default, the router will advertise this same loopback IP address as the NEXT_HOP
for all prefixes it originates or passes along to that eBGP peer.NEXT_HOP
address via its IGP (or static routes). It performs a recursive lookup in its RIB to find a path to the next-hop. If this lookup fails, the BGP path is considered invalid.In our scenario, R3 advertises its prefix with a next-hop of its own Loopback0. R1 receives this, but its recursive lookup for R3’s Loopback0 fails because that network is not present in its IGP routing table.
The community post hints at using a BGP feature to solve this. Let’s analyze a commonly misunderstood command in this context: next-hop-self
.
The command neighbor <ip-address> next-hop-self
is a powerful policy tool primarily designed for iBGP. When a router learns a route from an eBGP peer and advertises it to an iBGP peer, it leaves the NEXT_HOP
attribute unchanged by default. This often causes black-holing within the AS, as internal routers may not have a route to the external peer. next-hop-self
solves this by forcing the router to substitute its own address as the next-hop before sending the update to the iBGP peer.
Applying next-hop-self
to an eBGP peer, as in our R1-R3 scenario, is generally redundant. The router is already advertising its own peering address (the loopback) as the next-hop due to the update-source
command. Therefore, configuring neighbor <R1_Loopback_IP> next-hop-self
on R3 will not change the behavior and will not solve the reachability problem on R1.
The most elegant and scalable solution is to use a route-map on the advertising router (R3) to manually modify the NEXT_HOP
attribute for routes sent to R1. The goal is to change the next-hop from R3’s unreachable loopback address to an IP address that R1 can resolve via its IGP. The ideal candidate is the IP address of R3’s physical interface connected to the transit router, R2.
Implementation Steps (to be configured on R3):
Identify a Reachable Next-Hop:
Determine the IP address on R3 that is reachable from R1’s perspective. This would be the IP address of R3’s physical interface facing R2. Let’s assume this IP address is 10.23.1.3
. R1 can reach this address because its IGP provides a path to R2, which is directly connected to that network.
Create a Route-Map:
Define a route-map that sets the BGP next-hop to this reachable IP address.
! On Router R3
route-map SET-NEXT-HOP-R1 permit 10
set ip next-hop 10.23.1.3
!
This route-map, named SET-NEXT-HOP-R1
, will match any route passing through it and explicitly set the NEXT_HOP
attribute to 10.23.1.3
.
Apply the Route-Map to the eBGP Neighbor:
Apply this route-map in the outbound direction for the eBGP neighbor R1.
! On Router R3
router bgp 200
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 ebgp-multihop 2
! Apply the route-map for outbound updates to R1
neighbor 1.1.1.1 route-map SET-NEXT-HOP-R1 out
!
(Assuming R1’s Loopback0 is 1.1.1.1)
How This Solves the Problem:
route-map SET-NEXT-HOP-R1
is triggered.set ip next-hop 10.23.1.3
command overwrites the default next-hop (R3’s Loopback0) with the specified physical interface IP (10.23.1.3
).NEXT_HOP = 10.23.1.3
.10.23.1.3
. Since R1 has an IGP route towards R2, which can reach 10.23.1.3
, the lookup succeeds.*>
) in the BGP table and installed into the RIB and FIB.After applying the configuration, perform the following verification steps on R1:
clear ip bgp 1.1.1.1 soft in
show ip bgp 3.3.3.3
*>
.10.23.1.3
, and the path will be marked as valid and best (*>
).show ip route 3.3.3.3
10.23.1.3
.The issue of an inaccessible next-hop in multihop eBGP setups with segmented IGPs is a direct consequence of BGP’s route resolution mechanism. While commands like next-hop-self
are critical for iBGP stability, they do not address this specific eBGP problem. The definitive solution is to use BGP’s own policy framework—specifically, an outbound route-map—to manually set the NEXT_HOP
attribute to a reachable IP address. This method is clean, scalable, and keeps the control-plane logic within BGP, avoiding undesirable modifications to the IGP or reliance on static routing.