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.
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.
| Link | First endpoint | Second endpoint |
|---|---|---|
| R1–R2 | R1 Gi1: 192.0.2.1/30 | R2 Gi1: 192.0.2.2/30 |
| R2–R3 | R2 Gi2: 192.0.2.5/30 | R3 Gi1: 192.0.2.6/30 |
| R1–R4 | R1 Gi2: 192.0.2.9/30 | R4 Gi2: 192.0.2.10/30 |
| R4–R5 | R4 Gi1: 192.0.2.13/30 | R5 Gi1: 192.0.2.14/30 |
| R5–R6 | R5 Gi2: 192.0.2.17/30 | R6 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
endR2
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
endR3
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
endR4
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
endR5
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
endR6
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
endeBGP 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 iR3# 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 iThe 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 iR6# 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 iR6 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 GigabitEthernet1The 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 iR5# 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 iR5# show ip route 192.0.2.9
% Network not in table
R5# show ip route 10.255.0.1
% Network not in tableR5 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 iR1# 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 iR1# 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 GigabitEthernet2R1 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 lab | Observed result |
|---|---|
| eBGP route exported to eBGP | R2 changes the next hop to its R3-facing address. |
| Locally originated route sent to iBGP | R4 uses its peering loopback; R5 and R6 learn directly from R4. |
| eBGP route exported to iBGP | R4 preserves R1’s external next hop. |
| iBGP route exported to eBGP | R4 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.
Protocol reference
BGP NEXT_HOP rules and recursive resolution · Router-symbol attribution.