Prefer eBGP over iBGP
Reach the external-versus-internal comparison only after the earlier attributes tie, then distinguish it from administrative distance.
Three-router topology
R1 and R2 share AS 65012; both peer externally with R3 in AS 65030 and internally with each other. R3 originates a test /32. R1 and R2 also originate their respective R3-facing transit subnets so each can resolve the other’s preserved external next hop.
| Link | First endpoint | Second endpoint |
|---|---|---|
| R1–R2 | R1 GigabitEthernet1: 192.0.2.1/30 | R2 GigabitEthernet1: 192.0.2.2/30 |
| R1–R3 | R1 GigabitEthernet2: 192.0.2.5/30 | R3 GigabitEthernet1: 192.0.2.6/30 |
| R2–R3 | R2 GigabitEthernet2: 192.0.2.9/30 | R3 GigabitEthernet2: 192.0.2.10/30 |
Complete baseline 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.5 255.255.255.252
no shutdown
exit
router bgp 65012
bgp router-id 10.255.0.1
no bgp default ipv4-unicast
neighbor 192.0.2.2 remote-as 65012
neighbor 192.0.2.6 remote-as 65030
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.2 activate
neighbor 192.0.2.6 activate
network 192.0.2.4 mask 255.255.255.252
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.9 255.255.255.252
no shutdown
exit
router bgp 65012
bgp router-id 10.255.0.2
no bgp default ipv4-unicast
neighbor 192.0.2.1 remote-as 65012
neighbor 192.0.2.10 remote-as 65030
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.1 activate
neighbor 192.0.2.10 activate
network 192.0.2.8 mask 255.255.255.252
exit-address-family
endR3
hostname R3
ip cef
interface Loopback0
ip address 10.255.0.3 255.255.255.255
exit
interface Loopback10
ip address 203.0.113.3 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.6 255.255.255.252
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.10 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 65012
neighbor 192.0.2.9 remote-as 65012
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.5 activate
neighbor 192.0.2.9 activate
network 203.0.113.3 mask 255.255.255.255
exit-address-family
endCompare the two paths
R1# show ip bgp 203.0.113.3/32
Network Next Hop Metric LocPrf Weight Path
*> 203.0.113.3/32 192.0.2.6 0 0 65030 i
*i 192.0.2.10 0 100 0 65030 iR1# show ip route 203.0.113.3
Routing entry for 203.0.113.3/32
Known via "bgp 65012", distance 20, metric 0
* 192.0.2.6, via GigabitEthernet2Both paths are usable and tie on weight, effective local preference, local-origination status, AS-path length, ORIGIN and MED. The external path wins at session type; the later internal cost comparison is not needed.
Resolve the internal next hop
R1# show ip route 192.0.2.10
Routing entry for 192.0.2.8/30
Known via "bgp 65012", distance 200, metric 0
* 192.0.2.2, via GigabitEthernet1The alternative path is valid because R2 advertised its connected /30 internally. If that next hop were unresolved, the comparison would stop at eligibility instead of demonstrating eBGP preference. There is no next-hop-self policy in this baseline.
Let earlier policy win
On R2, set local preference 200 on the /32 learned from R3, then refresh that external neighbor.
ip prefix-list TARGET seq 5 permit 203.0.113.3/32
route-map PREFER-R2 permit 10
match ip address prefix-list TARGET
set local-preference 200
exit
route-map PREFER-R2 permit 20
exitrouter bgp 65012
address-family ipv4 unicast
neighbor 192.0.2.10 route-map PREFER-R2 in
exit-address-familyR2# clear ip bgp 192.0.2.10 soft inR1# show ip bgp 203.0.113.3/32
Network Next Hop Metric LocPrf Weight Path
* 203.0.113.3/32 192.0.2.6 0 0 65030 i
*>i 192.0.2.10 0 200 0 65030 iR1# show ip route 203.0.113.3
Routing entry for 203.0.113.3/32
Known via "bgp 65012", distance 200, metric 0
* 192.0.2.10The internal path now wins earlier at local preference. Its administrative distance is 200 rather than 20, yet it is the selected BGP candidate. Administrative distance compares route sources during IP-table installation; it is not the explanation for this BGP best-path step.
Restore the baseline
On R2, detach the inbound policy and refresh the external neighbor. R1 again prefers its usable direct external path.
router bgp 65012
address-family ipv4 unicast
no neighbor 192.0.2.10 route-map PREFER-R2 in
exit-address-familyR2# clear ip bgp 192.0.2.10 soft inR1# show ip bgp 203.0.113.3/32
Network Next Hop Metric LocPrf Weight Path
*> 203.0.113.3/32 192.0.2.6 0 0 65030 i
*i 192.0.2.10 0 100 0 65030 iKey Takeaways
- Usable eBGP paths are preferred over iBGP paths only when earlier comparisons tie.
- Both candidates must have reachable next hops for this experiment.
- Local preference can make an internal path win before session type is compared.
- A received external next hop can be resolved through an internally learned transit subnet.
- Administrative distance is separate from this BGP best-path comparison.
Protocol and command references
Best-path comparison rules · BGP path attributes · Router-symbol attribution.