Lesson Contents
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:
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:
- Weight is 0.
- Local preference is 100.
- Originate is the same because R3 advertised it.
- AS Path length is the same.
- Origin code (IGP).
- MED is the same.
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.
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.
Didnt got the AD value part
If lets say there is a router A
If it gets 2 routes of same prefix x.x.x.x/24 from ibgp and ebgp so it will select ebgp because ebgp has lower AD value of 20 compared to Ibgp which is 200 right ?
Its a bit confusing for me as i read ur notes
Hello Anoop
We must keep in mind the order of operations with which these processes take place.
The BGP router will first consider all of the possible routes that have been learned via BGP. These routes are all listed in the BGP table. From this, using the best path selection algorithm, BGP will choose the best one. Once this is done, that best path will then become a candidate to be installed in the routing table.
This candidate route will then be compared with routes to the same destination that have been learned from other routing protocols (if they exist
... Continue reading in our forumI guess we can say the Routing Table is the World Championships and in that best athletes (routes) from different countries (routing protocols ) participate .
So to identify the best athlete in a country is the responsibility of that country
So here BGP selects the best route to reach to x.x.x.x route and iBGP and eBGP give the best route and BGP says that for us eBGP is the better route and i am not checking the AD value its because of best path selection criteria
But then in the Routing Table (World championships) x.x.x.x route is given by lots of countries l
... Continue reading in our forumHello Anoop
Wow, that’s a great analogy! And it’s spot on! The only thing I would add is that BGP is a nation that is composed of two countries, iBGP and eBGP, in a similar way that the UK is composed of four. But only one of those two countries can compete for the nation.
BGP must have iBGP compete with eBGP if they both enter the national competition. eBGP will always win and will go to the world championships with an AD of 20. However, if eBGP does not enter the national competition at all, then iBGP wins by default, and it goes to the world championshi
... Continue reading in our forumHello Xinran
The prerequisite that exists for Autonomous Systems within which iBGP peers are deployed, is that there must be routing established such that all iBGP routers within the AS can reach each other.
When you have a large AS with multiple routers, you would typically deploy a routing protocol like OSPF or EIGRP to ensure that this prerequisite is fulfilled. However, if you just have two routers such as those in AS12, they are directly connected, and they already know how to reach each other via their directly connected network of 192.168.12.0/24. So t
... Continue reading in our forum