The AD of iBGP and eBGP are only compared whenyou receive routes from another protocol, that's why they were chosen this way because 200 is greater than any IGP and 20 less than any IGP.
Concerning the non advertisement of iBGP route to iBGP peer: this is a loop protection mechanism because we can't use AS_PATH like in eBGP so if you are running BGP in your AS you must either have a full mesh of iBGP peerings which is not very scalable or use Route Reflector which is a router not obeying the rule above( you could compare it to the DR in OSPF) or use confederations( you split your AS into multiple subASes in which the rule above still prevails and connect these subASes with special eBGP peering)
Now to my understanding iBGP routes = admin distance 200, and eBGP = admin distance 20. So this doesn't make sense to me. Can someone elaborate please?
A router has got a single BGP database. There is no way you'll have two same prefixes learnt from an eBGP connection and an iBGP connection competing for being installed into the routing table based on the admin distance. In fact, they will decide who is better based on the BGP best path selection algorithm first, before comparing admin distance of the prefixes learnt from different routing protocols.
When you choose the best route, your look at the prefix and its length first. Each routing protocol chooses its best route independently (there is no eBGP and iBGP routing protocols!), so the second step is to look at admin distance.
Also, what's he on about saying not to advertise iBGP learned routes to iBGP peers? How are you suppose to ever build an iBGP network if you never advertise networks to each other?
You cannot advertise a route to an iBGP neighbor if you learnt it from another iBGP neighbor. In this case E2 learns a route from ASN3 which is an eBGP connection. So E2 can pass that route to E1 over iBGP.
I think I understand what you're saying Alain. Are you saying that because iBGP routes are never shared between iBGP peers, admin distance is never really taken into account (as iBGP won't learn the internal routes anyway)?
I think i just understood why i got confused too! that route is an eBGP route. Although in the table for the #sh ip bgp on E1 it shows that:
this has an "i" for the route. It just means it was learnt via iBGP, even though it is an eBGP route.
suppose you have 5 routers: R1,R2,R3 are in your AS 1 and R4 in AS4 and R5 in AS5
you have eBGP R1-R4 and R2-R5 and iBGP R1-R3 and R2-R3 but not R1-R2.
You have an IGP running in your AS(EIGRP,OSPF or IS-IS).
Now when R4 advertises a network(eg 18.104.22.168/24) to R1 it will prepend its own AS and the next-hop will be the ip address of update-source.
R1 receives it and if next-hop is reachable then it is a best route which is installed in BGP table and in RIB. R1 is then going to advertise this network to R3 not modifying AS_PATH and not changing next-hop because it is an iBGP update now.
So when R3 receives it if next-hop is unreachable it is not considered best and so not installed in RIB and not advertised so if you want it to be best route you have to get reachability to next-hop. There are multiple ways to do this the simplest one being configuring next-hop-self on the iBGP neighbour relationship with R3 so when R3 receives route the next-hop is reachable via IGP and the route s considered best and marked with a lower i because it is an iBGP route.
In eBGP the loop prevention mechanism is the AS_PATH: once you see an update with your AS_PATH in then you drop it because it is a loop.
But in iBGP as you're not prepending the AS to the AS_PATH you can't detect a loop this way so came the iBGP split horizon rule which says never advertise an iBGP learned route to an iBGP peer.So here R3 won't advertise whatsoever the network from R4 to R2 and so R5 won't know about it.
There are multiple ways to solve this problem: the simplest but not very scalable method is to have a full mesh of iBGP peerings with the formula n(n-1)/2 so here we need 3(3-1)/2=3 peerings. Hee we have only 2 so we must also peer R1 with R2: this way R1 will advertise this network to R2 and R3 but R3 won't advertise it to R2.
So now R2 knows about it,has reachability to the next-hop and so it is a best route installed in rib and advertised to R5 with eBGP so we prepend our AS to AS_PATH and we modify next-hop.
Hope this was clear enough otherwise we can discuss about it via IM.
bgp decision steps: N WLLA OMNI
0- next hop reachable?
1 - weight (bigger is better)
2 - local preference (bigger is better)
3 - locally injected routes
4 - AS path (smaller is better)
5 - origin
6 - MED
7 - neighbor type (eBGP prefered than iBGP)
8 - IGP metric for next-hop
So in example network path through E2 will win because of AS path and iBGP doesn't matter.
I had the confusion until I watched the INE video on BGP. What you really need to understand is that the BGP best path algorithm first selects the best path based on the decisions steps mentioned by Borzol above. Once the best path has been selected, it will then be installed it into the routing table. It is only after then that the routing table will select the best route (which could be from other routing protocols i.e. OSPF, EIGRP, External BGP and Internal BGP) based on the administrative distance (AD). I hope this helps.
I’m at the same point in the book as the o.p.; I set up Odom’s network (see o.p.’s diagram) on GNS3 and found, contrary to Odom, E1 was choosing the external route (through ASN1) as best, not E2’s iBGP route (for 22.214.171.124/28); the problem, which I feel needs some clarification sooner than 5 sections later (6th edition?!?) is that E1 needs a route to 192.168.1.6 (Thanks cadetalain)… I’m sure this is obvious for most, but for others just learning and who are running his examples on GNS3…
On E2, under router bgp 11:
network 192.168.1.4 mask 255.255.255.252
neighbor 10.100.1.1 next-hop-self
E1 will now choose the iBGP route (through E2) as valid and best. I’m assuming the second option is the better practice?