Selection of iBGP & EBGP Paths

In a situation where a route coming from both ebgp and ibgp peer, the best path election will takes place in two different way. If the rote is locally originated then it will prefer ibgp path, otherwise it will chose ebgp path.

BGP Path Selection Criteria

In some cases a route can arrive to a Router via iBGP and EBGP both. Now the Router need to decide the best path from BGP Best Path Algorithm. It might seem that the EBGP routes would always be preferred but the choice depends on various conditions and path attributes.

Before jump into the examples, we need like to understand some basic path selection criteria.

  • A routes containing blank AS Path(or AS Path contains nothing/AS Path Unset) means its locally originated, thus injected from the same AS.
  • A routes being injected locally using redistribute, network or aggregate command will be having a weight of 65535.
  • The default value of LP is 100 while its learning from iBGP peer and LP is unset while learning from eBGP peer.
  • The comparison will only takes place while the PA Parameters will be set for the received routes.

Path Selection of iBGP over EBGP

In this discussion, we will look into the path selection of routes coming from both eBG & iBGP. The generic path selection algorithm will remain unaltered in such cases also. Refer to the below topology where two routers from different data centres are connected via an ISP Link and a backdoor link is connected as well.

We can further simply the above topology using three routers. R1, R2 & R3 are connected in a triangle where R1 & R2 are in AS 12 and R3 is in AS 3. Refer to the below diagram.

Configuration Example – iBGP over EBGP

R1 – Configuration

R1#
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface Ethernet0/0
ip address 12.0.0.1 255.255.255.0
no shut
!
interface Ethernet0/1
ip address 13.0.0.1 255.255.255.0
no shut
!
router bgp 12
bgp router-id 1.1.1.1
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255
neighbor 12.0.0.2 remote-as 12
neighbor 13.0.0.3 remote-as 3
neighbor 13.0.0.3 allowas-in
!
R1#

R2 – Configuration

R2#
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface Ethernet0/0
ip address 23.0.0.2 255.255.255.0
no cdp enable
!
interface Ethernet0/1
ip address 12.0.0.2 255.255.255.0
no cdp enable
!
router bgp 12
bgp router-id 2.2.2.2
bgp log-neighbor-changes
network 2.2.2.2 mask 255.255.255.255
neighbor 12.0.0.1 remote-as 12
neighbor 23.0.0.3 remote-as 3
neighbor 23.0.0.3 allowas-in
R2#


!
R2#

R3 – Configuration

R3#
!
interface Ethernet0/0
ip address 13.0.0.3 255.255.255.0
no cdp enable
!
interface Ethernet0/1
ip address 23.0.0.3 255.255.255.0
no cdp enable
!
router bgp 3
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 13.0.0.1 remote-as 12
neighbor 23.0.0.2 remote-as 12

!
R3#

Recall the Best Path Selection Algorithm once again.
Weight > LP > Originate(Injected/Locally Originated > Learned) > AS Path > Origin Code(e > i > ?) > MED > Path(EBGP > iBGP) > IGP Path > RID

R1 & R2 are both advertising its connected loopback subnet over EBGP and iBGP as well. On R1 the routes 2.2.2.2/32 will come via iBGP(from R2) and also via eBGP(from R3-R2). R1 will elect the iBGP routes as best since its is locally originated(route contains an empty AS Path/ AS Path is unset). The router R2 will also prefer the iBGP route in the same way.


So R1 & R2 are choosing the iBGP path due to locally originated(injected from the same AS). We can verify the outputs below. You can see the iBGP route is being identified as Local in the ‘show ip bgp 2.2.2.2/32’ of R1.

Locally Originated is Preferred over Leaned

Show Output – R1

R1#show ip bgp
BGP table version is 3, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *   1.1.1.1/32       13.0.0.3                               0 3 12 i
 *>                   0.0.0.0                  0         32768 i
 *   2.2.2.2/32       13.0.0.3                               0 3 12 i
 *>i                  12.0.0.2                 0    100      0 i
R1#
R1#show ip bgp 2.2.2.2/32
BGP routing table entry for 2.2.2.2/32, version 3
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     16
  Refresh Epoch 3
  3 12
    13.0.0.3 from 13.0.0.3 (3.3.3.3)
      Origin IGP, localpref 90, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 1
  Local 
    12.0.0.2 from 12.0.0.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      rx pathid: 0, tx pathid: 0x0
R1#

Show Output – R2

R2#show ip bgp
BGP table version is 3, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *   1.1.1.1/32       23.0.0.3                               0 3 12 i
 *>i                  12.0.0.1                 0    100      0 i
 *   2.2.2.2/32       23.0.0.3                               0 3 12 i
 *>                   0.0.0.0                  0         32768 i
R2#

Prefer EBGP over iBGP

Now we will check a condition where the routes are not locally injected but learned routes coming from both ebgp and ibgp peer.

In the above topology, the route 3.3.3.3/32 are being received at R1 via ebgp and ibgp as well. Both the routes are learned routes means not injected from it’s own AS. Now for the best path selection it will choose path (ebgp path will be preferred over ibgp path) thus will choose EBGP Peer R3 as best.

Additional Configuration to Inject the Loopback

R3 – Additional Configuration – Loopback 3.3.3.3/32

R3#
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
router bgp 3
bgp router-id 3.3.3.3
bgp log-neighbor-changes
network 3.3.3.3 mask 255.255.255.255
neighbor 13.0.0.1 remote-as 12
neighbor 23.0.0.2 remote-as 12
!

R1 – Outputs – EBGP Prefered – Path(EBGP over iBGP)

R1#show ip bgp
BGP table version is 4, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *   1.1.1.1/32       13.0.0.3                               0 3 12 i
 *>                   0.0.0.0                  0         32768 i
 *   2.2.2.2/32       13.0.0.3                               0 3 12 i
 *>i                  12.0.0.2                 0    100      0 i
 *>  3.3.3.3/32       13.0.0.3                 0             0 3 i
 * i                  12.0.0.2                 0    100      0 3 i
R1#show ip bgp 3.3.3.3/32
BGP routing table entry for 3.3.3.3/32, version 3
Paths: (2 available, best #1, table default)
  Advertised to update-groups:
     18
  Refresh Epoch 2
  3
    13.0.0.3 from 13.0.0.3 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0
  Refresh Epoch 1
  3
    12.0.0.2 from 12.0.0.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal
      rx pathid: 0, tx pathid: 0
R1#
  Previous Next  

Leave a Reply