PacketLab
BGP · Attributes and Path Selection

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.

Lab topologyIllustrative network
.1 / .2 · iBGP.5 / .6 · eBGP.9 / .10 · eBGPR1AS 65012R2AS 65012R3AS 65030
Solid lines: physical links. Link labels use the last octet of 192.0.2.x; every link is a separate /30. AS labels identify the protocol relationship. Loopback0 is 10.255.0.N/32 for router RN. Exact interfaces and subnets are listed below.
LinkFirst endpointSecond endpoint
R1–R2R1 GigabitEthernet1: 192.0.2.1/30R2 GigabitEthernet1: 192.0.2.2/30
R1–R3R1 GigabitEthernet2: 192.0.2.5/30R3 GigabitEthernet1: 192.0.2.6/30
R2–R3R2 GigabitEthernet2: 192.0.2.9/30R3 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
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.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
end

R3

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
end
Outputs are illustrative, not recorded router results. Each lesson is a separate lab. Allow updates to converge after changes; the selected baseline path is an example when all earlier criteria tie.

Compare 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 i
R1# 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 GigabitEthernet2

Both 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 GigabitEthernet1

The 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
exit
router bgp 65012
 address-family ipv4 unicast
  neighbor 192.0.2.10 route-map PREFER-R2 in
 exit-address-family
R2# clear ip bgp 192.0.2.10 soft in
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    200      0 65030 i
R1# 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.10

The 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-family
R2# clear ip bgp 192.0.2.10 soft in
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 i

Key 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.

External vs Internal Quiz

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

1. Two usable paths tie on earlier attributes. Which session type wins here?
2. An iBGP path has higher LOCAL_PREF. Must the eBGP path still win?
3. Why originate the external transit subnets internally in this lab?
4. Does distance 20 versus 200 explain the BGP best-path step itself?
5. What does leading i on the alternative path show?
6. After the preference experiment is removed, what should be rechecked?
Protocol and command references

Best-path comparison rules · BGP path attributes · Router-symbol attribution.