PacketLab
BGP · Reachability

BGP Next Hop: eBGP vs iBGP

The neighbor that sends an UPDATE and the next hop carried inside it are not always the same address. Follow four advertisements to see when that address changes.

Network and configuration

R1, R2 and R3 belong to separate ASes. R4, R5 and R6 share AS 65456. R1 also peers with R4. The three internal routers use OSPF for loopback reachability and form a full mesh of iBGP sessions sourced from Loopback0.

Six routers · four autonomous systemsIllustrative topology
AS 65456 · OSPF and full-mesh loopback iBGP12: 192.0.2.0/3023: 192.0.2.4/3014: 192.0.2.8/3045: 192.0.2.12/3056: 192.0.2.16/30R1Lo0: 10.255.0.1/32AS 65010R2Lo0: 10.255.0.2/32AS 65020R3Lo0: 10.255.0.3/32AS 65030R4Lo0: 10.255.0.4/32R5Lo0: 10.255.0.5/32R6Lo0: 10.255.0.6/32iBGP pairs: R4–R5, R4–R6, R5–R6 (logical sessions not drawn)
Solid lines show physical links. The numbers 12, 23, 14, 45 and 56 identify their endpoint routers. All three internal iBGP pairs exist even though only physical links are drawn.

Each router originates its own loopback /32. No next-hop rewriting policy is configured. The external-facing R1–R4 subnet is deliberately excluded from OSPF so that the unchanged next-hop problem remains visible.

LinkFirst endpointSecond endpoint
R1–R2R1 Gi1: 192.0.2.1/30R2 Gi1: 192.0.2.2/30
R2–R3R2 Gi2: 192.0.2.5/30R3 Gi1: 192.0.2.6/30
R1–R4R1 Gi2: 192.0.2.9/30R4 Gi2: 192.0.2.10/30
R4–R5R4 Gi1: 192.0.2.13/30R5 Gi1: 192.0.2.14/30
R5–R6R5 Gi2: 192.0.2.17/30R6 Gi1: 192.0.2.18/30
Complete router configurations

R1

hostname R1
ip cef
interface Loopback0
 ip address 10.255.0.1 255.255.255.255
exit
interface GigabitEthernet1
 ip address 192.0.2.1 255.255.255.252
 no shutdown
exit
interface GigabitEthernet2
 ip address 192.0.2.9 255.255.255.252
 no shutdown
exit
router bgp 65010
 bgp router-id 10.255.0.1
 no bgp default ipv4-unicast
 neighbor 192.0.2.2 remote-as 65020
 neighbor 192.0.2.10 remote-as 65456
 address-family ipv4 unicast
  network 10.255.0.1 mask 255.255.255.255
  neighbor 192.0.2.2 activate
  neighbor 192.0.2.10 activate
 exit-address-family
end

R2

hostname R2
ip cef
interface Loopback0
 ip address 10.255.0.2 255.255.255.255
exit
interface GigabitEthernet1
 ip address 192.0.2.2 255.255.255.252
 no shutdown
exit
interface GigabitEthernet2
 ip address 192.0.2.5 255.255.255.252
 no shutdown
exit
router bgp 65020
 bgp router-id 10.255.0.2
 no bgp default ipv4-unicast
 neighbor 192.0.2.1 remote-as 65010
 neighbor 192.0.2.6 remote-as 65030
 address-family ipv4 unicast
  network 10.255.0.2 mask 255.255.255.255
  neighbor 192.0.2.1 activate
  neighbor 192.0.2.6 activate
 exit-address-family
end

R3

hostname R3
ip cef
interface Loopback0
 ip address 10.255.0.3 255.255.255.255
exit
interface GigabitEthernet1
 ip address 192.0.2.6 255.255.255.252
 no shutdown
exit
router bgp 65030
 bgp router-id 10.255.0.3
 no bgp default ipv4-unicast
 neighbor 192.0.2.5 remote-as 65020
 address-family ipv4 unicast
  network 10.255.0.3 mask 255.255.255.255
  neighbor 192.0.2.5 activate
 exit-address-family
end

R4

hostname R4
ip cef
interface Loopback0
 ip address 10.255.0.4 255.255.255.255
exit
interface GigabitEthernet2
 ip address 192.0.2.10 255.255.255.252
 no shutdown
exit
interface GigabitEthernet1
 ip address 192.0.2.13 255.255.255.252
 no shutdown
exit
router ospf 1
 router-id 10.255.0.4
 network 10.255.0.4 0.0.0.0 area 0
 network 192.0.2.13 0.0.0.0 area 0
 passive-interface Loopback0
exit
router bgp 65456
 bgp router-id 10.255.0.4
 no bgp default ipv4-unicast
 neighbor 192.0.2.9 remote-as 65010
 neighbor 10.255.0.5 remote-as 65456
 neighbor 10.255.0.5 update-source Loopback0
 neighbor 10.255.0.6 remote-as 65456
 neighbor 10.255.0.6 update-source Loopback0
 address-family ipv4 unicast
  network 10.255.0.4 mask 255.255.255.255
  neighbor 192.0.2.9 activate
  neighbor 10.255.0.5 activate
  neighbor 10.255.0.6 activate
 exit-address-family
end

R5

hostname R5
ip cef
interface Loopback0
 ip address 10.255.0.5 255.255.255.255
exit
interface GigabitEthernet1
 ip address 192.0.2.14 255.255.255.252
 no shutdown
exit
interface GigabitEthernet2
 ip address 192.0.2.17 255.255.255.252
 no shutdown
exit
router ospf 1
 router-id 10.255.0.5
 network 10.255.0.5 0.0.0.0 area 0
 network 192.0.2.14 0.0.0.0 area 0
 network 192.0.2.17 0.0.0.0 area 0
 passive-interface Loopback0
exit
router bgp 65456
 bgp router-id 10.255.0.5
 no bgp default ipv4-unicast
 neighbor 10.255.0.4 remote-as 65456
 neighbor 10.255.0.4 update-source Loopback0
 neighbor 10.255.0.6 remote-as 65456
 neighbor 10.255.0.6 update-source Loopback0
 address-family ipv4 unicast
  network 10.255.0.5 mask 255.255.255.255
  neighbor 10.255.0.4 activate
  neighbor 10.255.0.6 activate
 exit-address-family
end

R6

hostname R6
ip cef
interface Loopback0
 ip address 10.255.0.6 255.255.255.255
exit
interface GigabitEthernet1
 ip address 192.0.2.18 255.255.255.252
 no shutdown
exit
router ospf 1
 router-id 10.255.0.6
 network 10.255.0.6 0.0.0.0 area 0
 network 192.0.2.18 0.0.0.0 area 0
 passive-interface Loopback0
exit
router bgp 65456
 bgp router-id 10.255.0.6
 no bgp default ipv4-unicast
 neighbor 10.255.0.4 remote-as 65456
 neighbor 10.255.0.4 update-source Loopback0
 neighbor 10.255.0.5 remote-as 65456
 neighbor 10.255.0.5 update-source Loopback0
 address-family ipv4 unicast
  network 10.255.0.6 mask 255.255.255.255
  neighbor 10.255.0.4 activate
  neighbor 10.255.0.5 activate
 exit-address-family
end
All transcripts below are illustrative excerpts, not recorded router output. Status and formatting can vary by software version. The BGP NEXT_HOP attribute is separate from the destination prefix in NLRI.

eBGP to eBGP

Start with R1’s loopback. R2 learns it with R1’s link address as the next hop. When R2 exports the route to R3, it changes the next hop to its own address on that different link.

R2# show ip bgp 10.255.0.1/32
     Network          Next Hop            Metric LocPrf Weight Path
*>   10.255.0.1/32    192.0.2.1            0             0 65010 i
R3# show ip bgp 10.255.0.1/32
     Network          Next Hop            Metric LocPrf Weight Path
*>   10.255.0.1/32    192.0.2.5                          0 65020 65010 i

The destination stays the same; the next hop changes at each external advertisement in this point-to-point lab. R3 forwards toward R2, rather than trying to reach R1’s interface directly.

iBGP to iBGP

Now inspect R4’s locally originated loopback on R5 and R6. R4 advertises directly to both internal peers using its peering loopback as next hop.

R5# show ip bgp 10.255.0.4/32
     Network          Next Hop            Metric LocPrf Weight Path
r>i  10.255.0.4/32    10.255.0.4           0    100      0 i
R6# show ip bgp 10.255.0.4/32
     Network          Next Hop            Metric LocPrf Weight Path
r>i  10.255.0.4/32    10.255.0.4           0    100      0 i

R6 receives this directly from R4, not through an ordinary R5 relay. An iBGP-learned route is not normally advertised to another iBGP peer. The leading i marks an internal path; the final i is the ORIGIN code.

R6# show ip route 10.255.0.4
Routing entry for 10.255.0.4/32
  Known via "ospf 1", distance 110, metric 3, type intra area
  * 192.0.2.17, via GigabitEthernet1

The r means RIB failure: OSPF supplies the installed route to the same /32 with a lower administrative distance than iBGP. The best BGP path remains visible; this is not a failed session. The metric shown is an example.

eBGP to iBGP

R4 learns R1’s loopback from eBGP, then advertises it internally. Without an explicit rewrite, the NEXT_HOP value remains R1’s external interface address.

R4# show ip bgp 10.255.0.1/32
     Network          Next Hop            Metric LocPrf Weight Path
*>   10.255.0.1/32    192.0.2.9            0             0 65010 i
R5# show ip bgp 10.255.0.1/32
     Network          Next Hop            Metric LocPrf Weight Path
i    10.255.0.1/32    192.0.2.9            0    100      0 65010 i
R5# show ip route 192.0.2.9
% Network not in table

R5# show ip route 10.255.0.1
% Network not in table

R5 knows how to reach its BGP peer R4’s loopback, but not the different address inside this route. With no route resolving that next hop, the path has no valid/best marker and cannot be installed. An Established session does not prove every advertised destination is usable.

The next lesson applies next-hop-self to this problem. This lesson keeps the default behavior intact.

iBGP to eBGP

Reverse direction and follow R6’s loopback. R4 receives it internally with R6 as next hop; R4 then exports the usable route to R1.

R4# show ip bgp 10.255.0.6/32
     Network          Next Hop            Metric LocPrf Weight Path
r>i  10.255.0.6/32    10.255.0.6           0    100      0 i
R1# show ip bgp 10.255.0.6/32
     Network          Next Hop            Metric LocPrf Weight Path
*>   10.255.0.6/32    192.0.2.10                         0 65456 i
R1# show ip route 10.255.0.6
Routing entry for 10.255.0.6/32
  Known via "bgp 65010", distance 20, metric 0
  * 192.0.2.10, via GigabitEthernet2

R1 uses the adjacent R4 address, not the remote R6 loopback, as its BGP next hop. Inside AS 65456, R4 recursively resolves R6 through OSPF. A BGP next hop can therefore differ from the immediate router reached on a physical link.

Next-hop comparison

Advertisement in this labObserved result
eBGP route exported to eBGPR2 changes the next hop to its R3-facing address.
Locally originated route sent to iBGPR4 uses its peering loopback; R5 and R6 learn directly from R4.
eBGP route exported to iBGPR4 preserves R1’s external next hop.
iBGP route exported to eBGPR4 uses its R1-facing address.

These are the defaults demonstrated by this topology, not an unconditional rule for every deployment. Shared-subnet third-party next hops and explicit policies can change external behavior. Always check both the advertised next hop and the IP route that resolves it.

Key Takeaways

  • In this point-to-point lab, exporting a route to eBGP normally sets the next hop to the advertising router’s address toward that peer.
  • A route learned externally normally retains its external next hop when advertised internally, unless policy rewrites it.
  • A locally originated route advertised to internal peers uses a suitable local next hop; here that is the originating router’s peering loopback.
  • A received BGP route needs a resolvable next hop before it can become a usable installed route.
  • The UPDATE sender, BGP next hop and immediate forwarding neighbor can be different addresses.

BGP Next Hop Quiz

Six questions · four options each · select one answer per question. Submit all answers to see your score and explanations.

1. R2 exports R1’s loopback route to R3 on a different point-to-point link. Which next hop does R3 see?
2. R4 passes R1’s external route to R5 without next-hop rewriting. What does R5 see?
3. R5 has an Established session with R4 but no route to the advertised next hop. What follows?
4. How does R6 learn R4’s locally originated loopback in this full mesh?
5. R4 exports the usable iBGP route for R6’s loopback to R1. Which next hop does R1 see here?
6. Why can R4’s loopback show r>i on R6 while an OSPF route is installed?
Protocol reference

BGP NEXT_HOP rules and recursive resolution · Router-symbol attribution.