BGP Prefer eBGP over iBGP

In the BGP attributes and path selection lesson, I explained that BGP uses a list of attributes to determine the best path. Somewhere down that list, one of the things BGP checks is whether we have an  (external BGP (eBGP) or internal BGP (iBGP) path.

BGP prefers eBGP paths over iBGP, which we’ll verify in this lesson.





Configuration

This is the topology we’ll use:

Bgp Prefer Ebgp Over Ibgp Topology

We have three routers in two ASes:

  • R1 and R2 are in AS1.
  • R3 is in AS3.

R3 advertises the 3.3.3.3/32 prefix on a loopback interface in BGP. R1 and R2 will learn about this prefix through eBGP, but they’ll also learn each other’s path through iBGP.

I use Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.9(3)M6, RELEASE SOFTWARE (fc1) on all routers.

Configurations

Want to take a look for yourself? Here, you will find the startup configuration of each device.

R1

hostname R1
!
ip cef
!
interface GigabitEthernet0/0
 ip address 192.168.12.1 255.255.255.0
!
interface GigabitEthernet0/1
 ip address 192.168.13.1 255.255.255.0
!
router bgp 12
 bgp router-id 1.1.1.1
 network 192.168.13.0 mask 255.255.255.0
 neighbor 192.168.12.2 remote-as 12
 neighbor 192.168.13.3 remote-as 3
!
end

R2

hostname R2
!
ip cef
!
interface GigabitEthernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface GigabitEthernet0/1
 ip address 192.168.23.2 255.255.255.0
!
router bgp 12
 bgp router-id 2.2.2.2
 network 192.168.23.0 mask 255.255.255.0
 neighbor 192.168.12.1 remote-as 12
 neighbor 192.168.23.3 remote-as 3
!
end

R3

hostname R3
!
ip cef
!
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface GigabitEthernet0/0
 ip address 192.168.13.3 255.255.255.0
!
interface GigabitEthernet0/1
 ip address 192.168.23.3 255.255.255.0
!
router bgp 3
 bgp router-id 3.3.3.3
 network 3.3.3.3 mask 255.255.255.255
 neighbor 192.168.13.1 remote-as 12
 neighbor 192.168.23.2 remote-as 12
!
end

Verification

We’ll have a look at the BGP table of R1. I’ll start with the show ip bgp command:

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, 
              t secondary path, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 * i  3.3.3.3/32       192.168.23.3             0    100      0 3 i
 *>                    192.168.13.3             0             0 3 i
 *>   192.168.13.0     0.0.0.0                  0         32768 i
 *>i  192.168.23.0     192.168.12.2             0    100      0 i

In the output above, we see two paths for 3.3.3.3/32:

  • Through R2 (192.168.23.3)
  • Through R3 (192.168.13.3)

The > symbol means that R1 installed this path as the best path. Why did it select this path as the best path? We’ll have to go through the list of attributes in the best path selection algorithm to answer that.

The output above shows some of the attributes we need to check, but not everything. I’ll run the show ip bgp command again and add the prefix we are interested in:

R1#show ip bgp 3.3.3.3
BGP routing table entry for 3.3.3.3/32, version 2
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     9         
  Refresh Epoch 1
  3
    192.168.23.3 from 192.168.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 1
  3
    192.168.13.3 from 192.168.13.3 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0

Now we have everything we need. All these attributes are the same for both paths, so they are not used as a tiebreaker:

The next item in the best path selection list prefers eBGP paths over BGP paths. That’s what is going on here. R1 has an eBGP path to R3 and an iBGP path through R2. R1 prefers the eBGP path and selects this as the best path.

Don’t confuse the BGP best path selection with administrative distance. A BGP router first has to figure out what the best path is in the BGP table. The next question is whether to install this path in the routing table or not. That’s when we look at administrative distance. A router will only compare its BGP best path against static routes or routes from IGPs such as OSPF or EIGRP. It will never compare an eBGP path against an iBGP path because that decision has already been made in the BGP table!

Conclusion

You have now learned how BGP prefers eBGP paths over iBGP paths. I hope you enjoyed this lesson. If you have any questions, feel free to leave a comment.


Source link

Leave a Reply